multimap


An associative container that manages a set of ordered key/value pairs. The pairs are ordered by key, based on a user-supplied comparator function. More than one value can be associated with a particular key. You can efficiently find all of these values due to multimap 's underlying data structure.

Library

Standards<ToolKit>

Declaration


#include <map>

template< class Key, class Value, class Compare, class Allocator >
class multimap

Interface

Constructor
multimap()
Constructs an empty multimap that orders its keys using the comparator Compare() , and uses Allocator() to manage storage.
Constructor
explicit multimap( const Compare& compare , const Allocator& alloc )
Constructs an empty multimap that orders its keys using the comparator compare , and uses alloc (default Allocator() ) to manage storage.
Constructor
multimap( const value_type* first , const value_type* last , const Compare& compare , const Allocator& alloc )
Constructs a multimap to contain copies of the key/value pairs in the range [ first , last } , using the comparator compare (default Compare() ) to order the keys and alloc (default Allocator() ) to manage storage.
Constructor
multimap( const_iterator first , const_iterator last , const Compare& compare , const Allocator& alloc )
Constructs a multimap to contain copies of the key/value pairs in the range [ first , last ) , using the comparator compare (default Compare() ) to order the keys and alloc (default Allocator() ) to manage storage.
Constructor
multimap( const multimap< Key, Value, Compare, Allocator >& other )
Constructs a copy of other .
Destructor
~multimap()
Destroys the multimap and erases all of its key/value pairs.
=
multimap< Key, Value, Compare, Allocator >& operator=( const multimap< Key, Value, Compare, Allocator >& other )
Replaces multimap's contents with a copy of other 's.
begin
iterator begin()
Returns an iterator positioned at the multimap's first key/value pair.
begin
const_iterator begin() const
Returns an iterator positioned at the multimap's first key/value pair.
clear
void clear()
Erases all of the multimap key/value pairs.
count
size_type count( const Key& key ) const
Returns the number of key/value pairs that the multimap contains with a key that matches key .
empty
bool empty() const
Returns true if the multimap contains no entries.
end
iterator end()
Returns an iterator positioned immediately after the multimap's last key/value pair.
end
const_iterator end() const
Returns an iterator positioned immediately after the last key/value pair.
equal_range
pair< iterator, iterator > equal_range( const Key& key )
Returns a pair of iterators with a first element that is equal to lower_bound() and with a second element that is equal to upper_bound() .
equal_range
pair< const_iterator, const_iterator > equal_range( const Key& key ) const
Returns a pair of iterators with a first element that is equal to lower_bound() and with a second element that is equal to upper_bound() .
erase
void erase( iterator pos )
Erases the key/value pair at pos .
erase
void erase( iterator first , iterator last )
Erases the key/value pairs in range [ first , last ) .
erase
size_type erase( const Key& key )
Erases all key/value pairs with a key that matches key and returns the number of elements erased.
find
iterator find( const Key& key ) const
If the multimap contains a key/value pair with a key that matches key , returns an iterator positioned at the matching pair. Otherwise, returns an iterator positioned at end() .
find
const_iterator find( const Key& key ) const
If the multimap contains a key/value pair with a key that matches key , returns a const iterator positioned at the matching pair. Otherwise, returns a const iterator positioned at end() .
get_allocator
Allocator get_allocator() const
Returns a copy of the allocator the multimap is using to manage storage.
insert
iterator insert( const value_type& pair )
Inserts a copy of the key/value pair pair , and returns an iterator to the new key/value pair.
insert
iterator insert( iterator pos , const value_type& pair )
Inserts a copy of pair , using pos as a hint on where to start searching for the correct place to insert.
insert
void insert( const value_type* first , const value_type* last )
Inserts copies of the key/value pairs in the range [ first , last ) .
insert
void insert( const_iterator first , const_iterator last )
Inserts copies of the key/value pairs in the range [ first , last ) .
key_comp
Compare key_comp() const
Returns the comparison object used to compare the multimap's keys.
lower_bound
iterator lower_bound( const Key& key )
Returns an iterator positioned at the first location a pair with key key can be inserted without violating the ordering criteria. If no such location is found, returns an iterator positioned at end() .
lower_bound
const_iterator lower_bound( const Key& key ) const
Returns an iterator positioned at the first location a pair with key key can be inserted without violating the ordering criteria. If no such location is found, returns an iterator positioned at end() .
max_size
size_type max_size() const
Returns the maximum number of key/value pairs that a multimap can contain.
rbegin
reverse_iterator rbegin()
Returns a reverse iterator positioned at the multimap's last key/value pair.
rbegin
const_reverse_iterator rbegin() const
Returns a reverse iterator positioned at the multimap's last key/value pair.
rend
reverse_iterator rend()
Returns a reverse iterator positioned immediately before the multimap's first key/value pair.
rend
const_reverse_iterator rend() const
Returns a reverse iterator positioned immediately before the multimap's first key/value pair.
size
size_type size() const
Returns the number of key/value pairs the multimap contains.
swap
void swap( multimap< Key, Value, Compare, Allocator >& other )
Exchanges the contents of multimap and other .
upper_bound
iterator upper_bound( const Key& key )
Returns an iterator positioned at the last location a pair with key key can be inserted without violating the ordering criteria. If no such location is found, returns an iterator positioned at end() .
upper_bound
const_iterator upper_bound( const Key& key ) const
Returns an iterator positioned at the last location a pair with key key can be inserted without violating the ordering criteria. If no such location is found, returns an iterator positioned at end() .
value_comp
value_compare value_comp() const
Returns the comparison object used to compare the multimap's key/value pairs.

Non-Member Functions

==
bool operator==( const multimap< Key, Value, Compare, Allocator >& x , const multimap< Key, Value, Compare, Allocator >& y )
Returns true if x contains the same items in the same order as y .
<
bool operator<( const multimap< Key, Value, Compare, Allocator >& x , const multimap< Key, Value, Compare, Allocator >& y )
Returns true if x is lexicographically less than y .
swap
void swap( const multimap< Key, Value, Compare, Allocator >& x , const multimap< Key, Value, Compare, Allocator >& y )
Exchanges the contents of x and y .

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.