When to use an Array vs When to use a Vector, when dealing with GameObjects?

Posted by user32465 on Game Development See other posts from Game Development or by user32465
Published on 2013-06-25T19:39:29Z Indexed on 2013/06/25 22:30 UTC
Read the original article Hit count: 222

Filed under:
|
|

I understand that from other answers, Arrays and Vectors are the best choices. Many on SE claim that Linked Lists and Maps are bad for video game programming.

I understand that for the most part, I can use Arrays. However, I don't really understand exactly when to use Vectors over Arrays.

Why even use Vectors? Wouldn't it be best if I simply always used an Array, that way I know how much memory my game needs?

Specifically my game would only ever load a single "Map" area of tiles, such as Map[100][100], so I could very easily have an array of GameObjectContainer GameObjects[100][100], which would reserve an entire map's worth of possible gameobjects, correct?

So why use a Vector instead? Memory is quite large on modern hardware.

© Game Development or respective owner

Related posts about vector

Related posts about data-structure