![]() |
![]() |
![]() |



multimap<> es el último contenedor asociativo. La diferencai entre map y multimap es identica a la que existe entre set y multiset. El multimap permite la existencia de claves duplicadas, y el map no.
La mayor diferencia respecto al map es la pérdida del operador []. Ahora no puede definirse porque al poder existir elementos repetidos ya no puede devolver una referencia a un elemento de tipo T. Para acceder a lo elementos de un multimap podemos utilizar los iteradoes hábituales y además los nuevos métodos lower_bound, upper_bound y equal_range.
template<class Key, class T, class Compare = less<Key>,
class Allocator = allocator>
class map
{
public:
// typedefs:
typedef Key key_type;
typedef pair<const Key, T> value_type:
typedef Compare key_compare;
class value_compare;
typedef iterator;
typedef const_iterator;
typedef Allocator<value_type>::pointer pointer;
typedef Allocator<value_type>::reference referente
typedef Allocator<value_type>::const_reference const_reference
typedef size_type;
typedef difference_type;
typedef reverse_iterator;
typedef const_reverse_iterator;
// allocation/deallocation:
map(const Compare& comp = Comp());
template<class InputIterator> map(InputIterator first,
InputIterator last,
const Compare& comp = Compare());
map(const map<Key, T, Compare, Allocator>& x);
~map();
map<Key, T, Compare, Allocator>&
operator=(const map<Key, T, Compare, Allocator>& x);
void swap(map<Key, T, Compare, Allocator>& x);
// accessors:
key_compare key_comp() const;
value_compare value_comp() const;
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
reverse_iterator rbegin();
const_reverse_iterator rbegin();
reverse_iterator rend();
const_reverse_iterator rend();
bool empty() const;
size_type size() const:
size_type max_size() const;
Allocator<T>::reference operator[](const key_type& x);
// insert/erase:
pair<iterator, bool> insert(const value_type& x);
iterator insert(iterator position, const value_type& x);
template<class InputIterator>
void insert(InputIterator first, InputIterator last);
void erase(iterator position);
size_type erase(const_My_type& x);
void erase(iterator first, iterator last);
// map operations:
iterator find(const key_type& x);
const_iterator find(const key_type& x) const;
size_type count(const key_type& x) const;
iterator lower_bound(const key_type& x);
const_iterator lower_bound(const key_type& x const);
iterator upper_bound(const key_type& x);
const_iterator upper_bound(const key_type& x) const;
pair<iterator, iterator> equal_range(const key_type& x);
pair<const_iterator, const_iterator> equal_range(const key_type& x) const;
};
template<class Key, class T, class Compare, class Allocator>
bool operator==(const map<Key, T, Compare, Allocator>& x,
const map<Key, T, Compare, Allocator>& y);
template<class Key, class T, class Compare, class Allocator>
bool operator<const map<Key, T, Compare, Allocator>& x,
const map<Key, T, Compare, Allocator>& y);
Los requisitos para los tipos Key y T son: