|
|
The containers defined by the STL are shown here:
Container | Description | Required Header |
---|---|---|
bitset | A set of bits | <bitset> |
deque | A double-ended queue | <deque> |
list | A linear list | <list> |
map | Stores key/value pairs in which each key is associated with only one value | <map> |
multimap | Stores key/value pairs in which one key may be associated with two or more values | <map> |
multiset | A set in which each element is not necessarily unique | <set> |
priority_queue | A priority queue | <queue> |
queue | A queue | <queue> |
set | A set in which each element is unique | <set> |
stack | A stack | <stack> |
vector | A dynamic array | <vector> |
Each of the containers is summarized in the following sections. Since the containers are implemented using template classes, various placeholder data types are used. In the descriptions, the generic type T represents the type of data stored by a container.
Since the names of the placeholder types in a template class are arbitrary, the container classes declare typedefed versions of these types. This makes the type names concrete. Here are the typedef names used by the container classes:
size_type | Some integral type roughly equivalent to size_t |
reference | A reference to an element |
const_reference | A const reference to an element |
difference_type | Can represent the difference between two addresses |
iterator | An iterator |
const_iterator | A const iterator |
reverse_iterator | A reverse iterator |
const_reverse_iterator | A const reverse iterator |
value_type | The type of a value stored in a container (often the same as the generic type T) |
allocator_type | The type of the allocator |
key_type | The type of a key |
key_compare | The type of a function that compares two keys |
mapped_type | The type of value stored in a map (same as the generic type T) |
value_compare | The type of a function that compares two values |
pointer | The type of a pointer |
const_pointer | The type of a const pointer |
container_type | The type of a container |
|
|