Using the Decision Trees
The decision trees start with an initial set of questions to determine whether you will use the container types set, map, list, or vector. Depending on your choice, additional decision trees help to further refine the type of collection you should use, depending on whether you are using collectable classes or templates.
Additional Selection Criteria
Which collection you choose will depend of many things (not the least of which will be your experience and intuition). In addition to the decision trees, the following questions will also influence your choice of container.
1. Do I need to maintain a single object in multiple collections? Use a pointer-based collection.
2. Am I collecting objects that are very expensive to copy? Use a pointer-based collection.
3. Is there no compelling reason to use a pointer-based collection? Use a value-based collection.
4. Do I want to control the order of the objects within the collection externally? Use a sequential collection such as a vector or list.
5. Should the items within the collection be mutable (not fixed) after they are inserted? Use a sequential or mapping (dictionary) collection. Maps and dictionaries have immutable keys but mutable values.
6. Would I prefer that the collection maintain its own order based on object comparison? Use a set, map, or sorted collection.
7. Do I wish to access objects within the collection based on a numerical index? Use a sequential or sorted collection.
8. Do I need to find values based on non-numeric keys? Use a map or dictionary.
9. Would I prefer to access objects within the collection by supplying an object for comparison? Use a set, map or hash-based collection.
10. Am I willing to forego meaningful ordering, and use some extra memory in return for constant-time look-up by key? Use a hash-based collection.
11. Do I need fast lookup and insertion in a collection that grows or shrinks to meet the current need? Use a b-tree, or an associative container based on the Standard C++ Library.
12. Do I need to access the data without bringing it all into memory? Use
RWBTreeOnDisk.