I am writing some UI stuff for my games in C++. Basically its a very common problem, but I dont know the best answer yet. Suppose inside my UI Library I have a view class which renders 2D/3D scene. This view can contain many subviews. I needs a container which allows me to iterate over these views fast and also insert/delete subviews. I am not sure which container is best for the job - list, vector or something else?
|
|
Chances are you'll be iterating over your collection a lot more than inserting/deleting screens, so Then again if you ask me I'll say never use I'll point to my answer in the when should vector/list be used question to go into more detail. Also, if you end up using |
|||||||||
|
|
Vector is a great choice- very fast iteration. You'd need an extremely high amount of Scenes to make inserting one, even at the beginning, to be slow for a vector. This is especially true if you're storing pointers rather than values. |
|||
|
|
|
The other option is |
|||
|
|
