STL Containers
STL Containers
Generic Containers
Container classes are building blocks used to create object oriented programs, and they
make the internals of a program much easier to construct.
A container class describes an object that holds other objects.
Container classes are so important that they were considered fundamental to early objectoriented languages.
The C++ approach to containers is based on templates. The containers in the Standard C+
+ library represent a broad range of data structures designed to work well with the standar
d algorithms and to meet common software development needs.
Containers
Iterators
Algorithms
in client-
Sequence Containers
Sequence Containers
Sequence containers maintain the ordering of inserted elements
that you specify.
A
vector
array
vector
, but the
deque
list
forward_list
version of
list
Associative Containers
map
key/value pair. The key is used to order the sequence, and the value
is associated with that key. For example, a map might contain keys
that represent every unique word in a text and corresponding values
that represent the number of times that each word appears in the
text. The unordered version of map is unordered_map . For more
information, see map Class and unordered_map Class.
A
set
set
is
unordered_set
. For
map
and
set
unordered_multimap
and
unordered_multiset
For
more
information,
Class, multiset
Class,
Container Adapters
queue
container follows FIFO (first in, first out) semantics. The first
priority_queue
the highest value is always first in the queue. For more information,
see priority_queue Class.
A
stack
container follows LIFO (last in, first out) semantics. The last
element pushed on the stack is the first element popped. For more
information, see stack Class.
Because container adapters do not support iterators, they cannot be
used with the STL algorithms. For more information, see Algorithms.