Thread: Minimizing array lookup times using effective indexing...?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788

    Minimizing array lookup times using effective indexing...?

    Hi

    I've decided to get into games development and have quite a bit of catching up to do.
    Currently, I'm writing a shmup engine (which I've done before, but I lost my code!).

    For my bullets, I have an object pool which can grow to +2000 objects very quickly.

    What strategies can I use to minimise the time to find an available object in the pool?

    Currently I'm using arrays for performance reasons, but I don't like the linear search required
    to find an available object...

    Any alternatives?

    [EDIT]
    I'm thinking of using a running index together with a stack for object's that die ie. when an object in the pool dies,
    push the index of that object onto the stack. In this way I could use the stack until it's empty before I initiate a linear search.
    Come to think of it, I could push all indexes onto the stack and then use the stack exclusively... Any suggestions?

    Thanks
    Last edited by The Dog; 02-07-2011 at 04:18 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Modify an single passed array element
    By swgh in forum C Programming
    Replies: 3
    Last Post: 08-04-2007, 08:58 AM
  2. how can I re-sort a map
    By indigo0086 in forum C++ Programming
    Replies: 8
    Last Post: 06-01-2006, 06:21 AM
  3. two dimensional dynamic array?
    By ichijoji in forum C++ Programming
    Replies: 6
    Last Post: 04-14-2003, 04:27 PM
  4. Creating 2D arrays on heap
    By sundeeptuteja in forum C++ Programming
    Replies: 6
    Last Post: 08-16-2002, 11:44 AM
  5. mode of an array
    By Need Help in forum C Programming
    Replies: 15
    Last Post: 09-17-2001, 08:03 AM