Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
STL Containers
bitset
deque
list
map
multimap
multiset
priority_queue
queue
set
stack
vector
multimap
comparison operators
multimap::multimap
multimap::~multimap
member functions:
multimap::begin
multimap::clear
multimap::count
multimap::empty
multimap::end
multimap::equal_range
multimap::erase
multimap::find
multimap::get_allocator
multimap::insert
multimap::key_comp
multimap::lower_bound
multimap::max_size
multimap::operator=
multimap::rbegin
multimap::rend
multimap::size
multimap::swap
multimap::upper_bound
multimap::value_comp


multimap

class template
<map>

Multiple-key map

Maps are a kind of associative container 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:
1
2
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


Iterators:

Capacity:

Modifiers:

Observers:

Operations:

Allocator:

Member types

of template <class Key, class T, class Compare=less<Key>, class Allocator=allocator<pair <const Key, T> > > class multimap;
member typedefinition
key_typeKey
mapped_typeT
value_typepair<const Key,T>
key_compareCompare
value_compareNested class to compare elements (see member function value_comp)
allocator_typeAllocator
referenceAllocator::reference
const_referenceAllocator::const_reference
iteratorBidirectional iterator
const_iteratorConstant bidirectional iterator
size_typeUnsigned integral type (usually same as size_t)
difference_typeSigned integral type (usually same as ptrdiff_t)
pointerAllocator::pointer
const_pointerAllocator::const_pointer
reverse_iteratorreverse_iterator<iterator>
const_reverse_iteratorreverse_iterator<const_iterator>