Search:

Type: Posts; User: Araanor

Search: Search took 0.00 seconds.

  1. Replies
    51
    Views
    3,590

    This one puzzles me. Any particular reason you're...

    This one puzzles me. Any particular reason you're using --i instead of i--? I can't make out any difference to a for-header.

    Some kind of convention for reverse iteration?
  2. Replies
    51
    Views
    3,590

    Optimization. The class uses an array to store...

    Optimization. The class uses an array to store objects, I found this to be the most efficient and clean way to implement it.
    The alternative would have been to do new ObjectType[someSize] when...
  3. Replies
    51
    Views
    3,590

    Ah, I see. Thank you.

    Ah, I see. Thank you.
  4. Replies
    51
    Views
    3,590

    You know, I thought I asked if it would work....

    You know, I thought I asked if it would work. Does the cast produce undefined behaviour?
  5. Replies
    51
    Views
    3,590

    Yes. Here's how I do it now: void...

    Yes.


    Here's how I do it now:


    void *mMemory;
    ObjectType *mObjectArray;
    ...
    // Allocate memory
  6. Replies
    51
    Views
    3,590

    No, I don't want char. I don't even want an array...

    No, I don't want char. I don't even want an array of my_object. I want a region of memory where I can put my objects. CornedBee made a good post on how this is possible. I'd only be casting from...
  7. Replies
    51
    Views
    3,590

    You're right. I realise the problems with...

    You're right.

    I realise the problems with messing around with memory management. If the class proves to be too much trouble, I'll eject it. But until then, I'll see it to a somewhat finished...
  8. Replies
    51
    Views
    3,590

    That's good advice, but I wanted deletion in...

    That's good advice, but I wanted deletion in constant time.

    I'll keep the original type of the pointers - I just thought of a new kludge instead! Which is:

    union
    {
    void *mMemory
    ObjectType...
  9. Replies
    51
    Views
    3,590

    You'll just love to hear that this is the first...

    You'll just love to hear that this is the first class I'm writing. :D

    Right, some background then. I had a chat with a professional game developer some time back where he told me he sped up their...
  10. Replies
    51
    Views
    3,590

    A linked list would imply links. The class...

    A linked list would imply links.

    The class uses an array so the objects can be stored in sequence and not be fragmented across memory.
    O(1) is achieved for insertion by inserting items at the end...
  11. Replies
    51
    Views
    3,590

    Sure. Which is the problem, I just wanted a...

    Sure.

    Which is the problem, I just wanted a raw memory block.


    Oh, the destructors, that's right... Always some detail.

    Thank you, that looks better. I just settled for char after reading a...
  12. Replies
    51
    Views
    3,590

    Undefined, you say. What if I do this: ...

    Undefined, you say.

    What if I do this:

    delete[] (char *) mArray;
    :D
  13. Replies
    51
    Views
    3,590

    Thanks. I'm writing a fast list-class with an...

    Thanks.

    I'm writing a fast list-class with an array underneath and insertion and deletion in O(1). I'd use the stl vector otherwise.
  14. Replies
    51
    Views
    3,590

    This discussion just touched an issue I'm...

    This discussion just touched an issue I'm contemplating.

    First, I have an allocation that looks lite this:

    ObjectType *mArray = (ObjectType *) new char[sizeof(ObjectType) * iInitialSize];
    ...
Results 1 to 14 of 14