Is this the best way to do this?

I plan to use a (not std) linked list in a 3d game to list game object entities. The way this would work is the program would go through each game object node and call a function to check if it is close enough to the player to render. Each node that is close enough to render gets copied and put in another linked list. The second linked list will be run through, this time calling a render function.

Is this efficient? Or is there a better way to do this?
No, I think it's safe to say that you should never used a linked list in game programming (well, I guess in a few places it's acceptable, like in a HUD, and stated below). When programming games, it's best to get everything in a contiguous block of memory, almost eliminating the probability of a cache miss. Try a std::vector instead, or even a c array.

I would say using a linked list is justifiable when you use the linked list to point to elements in the contiguous array, but not just randomly new'd single object. A linked list would definitely be better than brute-forcing through the array at render time.
Topic archived. No new replies allowed.