Multiple-key map
Maps are a kind of associative containers that stores elements formed by the combination of a key value and a mapped value, much like map containers, but allowing different elements to have the same key value.
In their implementation in the C++ Standard Template Library, multimap containers take four template parameters:
template < class Key, class T, class Compare = less<Key>,
class Allocator = allocator<pair<const Key,T> > > class multimap;
|
Where the template parameters have the following meanings:
- Key: Type of the key values. Each element in a multimap is generally identified by its key value, although multiple elements can have the same key value.
- T: Type of the mapped value. Each element in a multimap is used to store some data as its mapped value.
- Compare: Comparison class: A class that takes two arguments of the key type and returns a bool. The expression comp(a,b), where comp is an object of this comparison class and a and b are key values, shall return true if a is to be placed at an earlier position than b in a strict weak ordering operation. This can either be a class implementing a function call operator or a pointer to a function (see constructor for an example). This defaults to less<Key>, which returns the same as applying the less-than operator (a<b).
The multimap object uses this expression to determine the position of the elements in the container. All elements in a multimap container are ordered following this rule at all times.
- Allocator: Type of the allocator object used to define the storage allocation model. By default, the allocator class template is used, which defines the simplest memory allocation model and is value-independent.
In the reference for the
multimap member functions, these same names (
Key,
T,
Compare and
Allocator) are assumed for the template parameters.
The multimap class template is defined in header <map>.
See the description of its sibling map class template for more info.
Member functions
operator= | Copy container content (public member function) |
Iterators:
begin | Return iterator to beginning (public member function) |
end | Return iterator to end (public member function) |
rbegin | Return reverse iterator to reverse beginning (public member function) |
rend | Return reverse iterator to reverse end (public member function) |
Capacity:
empty | Test whether container is empty (public member function) |
size | Return container size (public member function) |
max_size | Return maximum size (public member function) |
Modifiers:
insert | Insert element (public member function) |
erase | Erase elements (public member function) |
swap | Swap content (public member function) |
clear | Clear content (public member function) |
Observers:
key_comp | Return key comparison object (public member function) |
value_comp | Return value comparison object (public member function) |
Operations:
find | Get iterator to element (public member function) |
count | Count elements with a specific key (public member function) |
lower_bound | Return iterator to lower bound (public member function) |
upper_bound | Return iterator to upper bound (public member function) |
equal_range | Get range of equal elements (public member function) |
Allocator:
Member types
of
template <class Key, class T, class Compare=less<Key>, class Allocator=allocator<pair <const Key, T> > > class multimap;
member type | definition |
key_type | Key |
mapped_type | T |
value_type | pair<const Key,T> |
key_compare | Compare |
value_compare | Nested class to compare elements (see member function value_comp) |
allocator_type | Allocator |
reference | Allocator::reference |
const_reference | Allocator::const_reference |
iterator | Bidirectional iterator |
const_iterator | Constant bidirectional iterator |
size_type | Unsigned integral type (usually same as size_t) |
difference_type | Signed integral type (usually same as ptrdiff_t) |
pointer | Allocator::pointer |
const_pointer | Allocator::const_pointer |
reverse_iterator | reverse_iterator<iterator> |
const_reverse_iterator | reverse_iterator<const_iterator> |