Friday, July 16, 2010

STL Containers

There are two categories of STL containers
  • Sequence containers: Variable sized and store elements in the original order
    • std::vector, C-style array that is re-sizable and must be the default choice. Element access can be performed in constant time. We can access the elements with a pointer like syntax *(vect.begin() + location).
    • std::list, doubly linked lists
    • std::deque, a vector that can be used to add items at the beginning
  • Sorted Associative Containers: Hold data in a sorted data structure and are optimized for fast lookup of elements
    • std::set, fast lookup of the elements, uses its own find algorithm
    • std::multiset
    • std::map, key value pair instead of plain objects
    • std::multimap, stores more than one key-value pair that have the same key

No comments:

Post a Comment