C++ Language/Std/Stl/CollectionClasses/SortedCollections

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Some STL collection classes are "sorted", in the sense that the class' items are internally stored using a tree data structure. Each item contains a "key", and the tree data structure maintains a property whereby the items are sorted by that key. As a result, client code can still iterate over the data structure from a "beginning" (item having the smallest key) to an "ending" (item having the largest key), even though that data isn't being linearly-stored. To define the sorting of keys, a sorted collection object is associated with a "sort-class" object.

  1. A Pair as one Item
  2. Tuple
  3. Map
  4. Multimap
  5. Set
  6. Multiset
  7. Hash-Table