The Associative containers implement an associative array which is composed of key+value bindings (pairs) and allows efficiently access the value by the key.
There are two kind of the associative containers
Multi associative container is the container which allows to store multiple values with the same key. Both the map and set containes have Multi associative container implementation.
And there are two major approaches how to implement the associative array:
Interface | ||||
---|---|---|---|---|
Static | Iterate from |
[Const::][Reverse::]Iterator |
[c][r]begin() [c][r]end() |
[const] |
Access to | [Const::]Iterator::Return::Type | front() back() |
||
Look up by a key | UInt | count(const Key &) | const | |
[Const::]Iterator | find(const Key &) | [const] | ||
equalRange(const Key &) | ||||
Dynamic | Where to insert | What to insert | ||
By a hint | [Const::][Reverse::]Iterator (in case of Multi::) | Insert::Result<[Const::][Reverse::]Iterator> |
insert([const [Const::][Reverse::]Iterator &hint,] |
Type && | const Type & | Type & | UInt count, const Type & | const Range/Contaner & | const RangeIterator &first, const RangeIterator &last) |
|
By a key (map only) | Type & | operator[](const Key &) | (inserts new Type()) | |
Were to erase | What to erase | |||
At position/range | Void | erase( | const [Const::][Reverse::]Iterator &[, const [Const::][Reverse::]Iterator &]| const Range &) |
|
By a key | UInt | erase( | const Key &) | |
Entirely | Void | clear() |
There are several implementations of the associative array container:
Operations | Binary:: Search:: Tree |
Binary:: Search:: RB::Tree |
(until C++11) | Hash:: Chaining:: Table |
Unordered:: | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Multi:: | Multi:: | |||||||||||||
Set | Map | Set | Map | Set | Map | Set | Map | |||||||
Static | Types |
typename | Type | |||||||||||
typename | Key | |||||||||||||
typename | Iterator | |||||||||||||
typename | Reverse::Iterator | |||||||||||||
typename | Const::Iterator | |||||||||||||
typename | Const::Reverse::Iterator | |||||||||||||
Iteration |
Iterator | begin() | ||||||||||||
Iterator | end () | |||||||||||||
Const::Iterator | begin() const | |||||||||||||
Const::Iterator | end () const | |||||||||||||
Const::Iterator | cbegin() const | |||||||||||||
Const::Iterator | cend () const | |||||||||||||
Reverse::Iterator | rbegin() | |||||||||||||
Reverse::Iterator | rend () | |||||||||||||
Const::Reverse::Iterator | rbegin() const | |||||||||||||
Const::Reverse::Iterator | rend () const | |||||||||||||
Const::Reverse::Iterator | crbegin() const | |||||||||||||
Const::Reverse::Iterator | crend () const | |||||||||||||
Capacity |
UInt | size() const | ||||||||||||
Bool | empty() const | |||||||||||||
Element access |
Iterator::Return::Type | front() | ||||||||||||
Const::Iterator::Return::Type | front() const | |||||||||||||
Iterator::Return::Type | back() | |||||||||||||
Const::Iterator::Return::Type | back() const | |||||||||||||
Iterator | find(const Key &) | |||||||||||||
Const::Iterator | find(const Key &) const | |||||||||||||
Iterator | equalRange(const Key &) | |||||||||||||
Const::Iterator | equalRange(const Key &) const | |||||||||||||
Counting | UInt | count(const Key &) const | ||||||||||||
Comparison |
template <typename U> Bool |
operator == (const U &u) const | ||||||||||||
template <typename U> Bool |
operator != (const U &u) const | |||||||||||||
template <typename Range> Bool |
equal(const Range &range) const | |||||||||||||
template <typename How, typename Range> Bool |
equal(const Range &range, const How &how = How()) const | |||||||||||||
template <typename How, typename Iterator> Bool |
equal(const Iterator &begin, const Iterator &end, const How &how = How()) const | |||||||||||||
Relational |
template <typename U> Int |
operator – (const U &u) const | ||||||||||||
template <typename U> Bool |
operator > (const U &u) const | |||||||||||||
template <typename U> Bool |
operator >= (const U &u) const | |||||||||||||
template <typename U> Bool |
operator < (const U &u) const | |||||||||||||
template <typename U> Bool |
operator <= (const U &u) const | |||||||||||||
template <typename Range> Int |
different(const Range &range) const | |||||||||||||
template <typename How, typename Range> Int |
different(const Range &range, const How &how = How()) const | |||||||||||||
template <typename How, typename Iterator> Int |
different(const Iterator &begin, const Iterator &end, const How &how = How()) const | |||||||||||||
Dynamic | Capacity | UInt | maxSize() const | |||||||||||
Modifiers |
T & | operator[](const Key &key) | ||||||||||||
T & | operator[](Key &&key) | |||||||||||||
T & | at(const Key &key) | |||||||||||||
T & | at(Key &&key) | |||||||||||||
T & | at(Key &&key) | |||||||||||||
Not::Multi::Insert::Interface & | Unique() | |||||||||||||
const Not::Multi::Insert::Interface & | Unique() const | |||||||||||||
Insert::Result<Iterator> | Iterator (in case of Multi::) |
insert(Type &&value) | |||||||||||||
Insert::Result<Iterator> | Iterator (in case of Multi::) |
insert(const Type &value) | |||||||||||||
Insert::Result<Iterator> | Iterator (in case of Multi::) |
insert(Type &value) | |||||||||||||
template <typename Iterator> Insert::Result<Iterator> | Iterator (in case of Multi::) |
insert(const Iterator &hint, Type &&value) | |||||||||||||
template <typename Iterator> Insert::Result<Iterator> | Iterator (in case of Multi::) |
insert(const Iterator &hint, const Type &value) | |||||||||||||
template <typename Iterator> Insert::Result<Iterator> | Iterator (in case of Multi::) |
insert(const Iterator &hint, Type &value) | |||||||||||||
template Void |
insert(const Range &range) | |||||||||||||
template Void |
insert(const RangeIterator &first, const RangeIterator &last) | |||||||||||||
Void | insert(const LWF::Initializer::List |
|||||||||||||
Void | erase(const Key &key) | |||||||||||||
Void | erase(const Iterator &iterator) | |||||||||||||
Void | erase(const Iterator &first, const Iterator& last) | |||||||||||||
Void | swap(Container &container) |