Introduction to Container Library
A container is a holder object that stores a collection of other objects . They are implemented as class templates, which allows a great flexibility in the types supported as elements.
The container manages the storage space for its elements and provides member functions to access them, either directly or through iterators .
Many containers have several member functions in common, and share functionalities. The decision of which type of container to use for a specific need does not generally depend only on the functionality offered by the container, but also on the efficiency of some of its members .
Different type of Containers in C++
Sequence containers implement data structures which can be accessed sequentially
Container adaptors provide a different interface for sequential containers.
- stack: Adapts a container to provide stack .
- queue: Adapts a container to provide queue .
- priority_queue: Adapts a container to provide priority queue .
3) Associative containers:-
Associative containers implement sorted data structures that can be quickly searched .
- Set: Collection of unique keys, sorted by keys
- Map: Collection of key-value pairs, sorted by keys, keys are unique .
- multiset: Collection of keys, sorted by keys .
- multimap: Collection of key-value pairs, sorted by keys
4)Unordered associative containers:-
Unordered associative containers implement unsorted data structures that can be quickly searched .