<unordered_map>

Description
Synopsis
Classes

Description

Include the STL standard header <unordered_map> to define the container template classes unordered_map and unordered_multimap, and their supporting templates.

Note:
To enable this header file, you must define the macro __IBMCPP_TR1__ .

Synopsis

namespace std {
    namespace tr1 {
    // DECLARATIONS
template <class Key, class Ty, class Hash, class Pred, class Alloc>
    class unordered_map;
template <class Key, class Ty, class Hash, class Pred, class Alloc>
    class unordered_multimap;

    // TEMPLATE FUNCTIONS
template <class Key, class Ty, class Hash, class Pred, class Alloc>
    void swap(
        unordered_map<Key, Ty, Hash, Pred, Alloc>& left,
        unordered_map<Key, Ty, Hash, Pred, Alloc>& right);
template <class Key, class Ty, class Hash, class Pred, class Alloc>
    void swap(
        unordered_multimap<Key, Ty, Hash, Pred, Alloc>& left,
        unordered_multimap<Key, Ty, Hash, Pred, Alloc>& right);
    } // namespace tr1
} // namespace std

Classes

unordered_map
unordered_multimap

unordered_map

Description
Synopsis
Constructor
unordered_map::unordered_map
Types
unordered_map::allocator_type
unordered_map::const_iterator
unordered_map::const_local_iterator
unordered_map::const_pointer
unordered_map::const_reference
unordered_map::difference_type
unordered_map::hasher
unordered_map::iterator
unordered_map::key_equal
unordered_map::key_type
unordered_map::local_iterator
unordered_map::mapped_type
unordered_map::pointer
unordered_map::reference
unordered_map::size_type
unordered_map::value_type
Member functions
unordered_map::begin
unordered_map::bucket
unordered_map::bucket_count
unordered_map::bucket_size
unordered_map::clear
unordered_map::count
unordered_map::empty
unordered_map::end
unordered_map::equal_range
unordered_map::erase
unordered_map::find
unordered_map::get_allocator
unordered_map::hash_function
unordered_map::insert
unordered_map::key_eq
unordered_map::load_factor
unordered_map::max_bucket_count
unordered_map::max_load_factor
unordered_map::max_size
unordered_map::operator[]
unordered_map::rehash
unordered_map::size
unordered_map::swap
Description

The template class describes an object that controls a varying-length sequence of elements of type std::pair<const Key, Ty>. The sequence is weakly ordered by a hash function, which partitions the sequence into an ordered set of subsequences called buckets. Within each bucket a comparison function determines whether any pair of elements has equivalent ordering. Each element stores two objects, a sort key and a value. The sequence is represented in a way that permits lookup, insertion, and removal of an arbitrary element with a number of operations that can be independent of the number of elements in the sequence (constant time), at least when all buckets are of roughly equal length. In the worst case, when all of the elements are in one bucket, the number of operations is proportional to the number of elements in the sequence (linear time). Moreover, inserting an element invalidates no iterators, and removing an element invalidates only those iterators which point at the removed element.

The object orders the sequence it controls by calling two stored objects, a comparison function object of type key_equal and a hash function object of type hasher. You access the first stored object by calling the member function key_eq(); and you access the second stored object by calling the member function hash_function(). Specifically, for all values X and Y of type Key, the call key_eq()(X, Y) returns true only if the two argument values have equivalent ordering; the call hash_function()(keyval) yields a distribution of values of type size_t. Unlike template class unordered_multimap, an object of template class unordered_map ensures that key_eq()(X, Y) is always false for any two elements of the controlled sequence. (Keys are unique.)

The object also stores a maximum load factor, which specifies the maximum desired average number of elements per bucket. If inserting an element causes load_factor() to exceed the maximum load factor, the container increases the number of buckets and rebuilds the hash table as needed.

The actual order of elements in the controlled sequence depends on the hash function, the comparison function, the order of insertion, the maximum load factor, and the current number of buckets. You cannot in general predict the order of elements in the controlled sequence. You can always be assured, however, that any subset of elements that have equivalent ordering are adjacent in the controlled sequence.

The object allocates and frees storage for the sequence it controls through a stored allocator object of type allocator_type. Such an allocator object must have the same external interface as an object of template class allocator. Note that the stored allocator object is not copied when the container object is assigned.

Synopsis
template <class Key,
    class Ty,
    class Hash  = std::tr1::hash<Key>,
    class Pred  = std::equal_to<Key>,
    class Alloc= std::allocator<Key> >
    class unordered_map {
public:
    typedef Key key_type;    
    typedef Ty mapped_type;
    typedef std::pair<const Key, Ty> value_type;
    typedef Hash hasher;
    typedef Pred key_equal;
    typedef Alloc allocator_type;

    typedef Alloc::pointer pointer;
    typedef Alloc::const_pointer const_pointer;
    typedef Alloc::reference reference;
    typedef Alloc::const_reference const_reference;

    typedef T0 iterator;
    typedef T1 const_iterator;
    typedef T2 size_type;
    typedef T3 difference_type;        
    typedef T4 local_iterator;
    typedef T5 const_local_iterator;

    unordered_map(
        const unordered_map& right);
    explicit unordered_map(
        size_type nbuckets = N0,
        const Hash& hfn = Hash(),
        const Pred& comp = Pred(),
        const Alloc& al = Alloc());
    template <class InIt>
        unordered_map(
        InIt first, InIt last,        
        size_type nbuckets = N0,
        const Hash& hfn = Hash(),
        const Pred& comp = Pred(),
        const Alloc& al = Alloc());
    
    iterator begin();
    const_iterator begin() const;
    local_iterator begin(size_type nbucket);
    const_local_iterator begin(size_type nbucket) const;

    iterator end();
    const_iterator end() const;
    local_iterator end(size_type nbucket);
    const_local_iterator end(size_type nbucket) const;

    size_type bucket_count() const;
    size_type max_bucket_count() const;
    size_type bucket(const Key& keyval) const;
    size_type bucket_size(size_type nbucket) const;
    
    Hash hash_function() const;
    Pred key_eq() const;
    Alloc get_allocator() const;

    float load_factor() const;
    float max_load_factor() const;
    void max_load_factor(float factor);
    void rehash(size_type nbuckets);

    Ty operator[](const Key& keyval);

    std::pair<iterator, bool> insert(const value_type& val);
    iterator insert(iterator where, const value_type& val);
    template<class InIt>
        void insert(InIt first, InIt last);

    iterator erase(iterator where);
    iterator erase(iterator first, iterator last);
    size_type erase(const Key& keyval);
    void clear();

    void swap(unordered_map& right);

    const_iterator find(const Key& keyval) const;
    size_type count(const Key& keyval) const;
    std::pair<iterator, iterator>
        equal_range(const Key& keyval);
    std::pair<const_iterator, const_iterator>
        equal_range(const Key& keyval) const;
    };
Constructor
unordered_map::unordered_map
unordered_map(
    const unordered_map& right);
explicit unordered_map(
   size_type nbuckets = N0,
    const Hash& hfn = Hash(),
    const Pred& comp = Pred(),
    const Alloc& al = Alloc());
template <class InIt>
  unordered_map(
    InIt first, InIt last,
    size_type nbuckets = N0,
    const Hash& hfn = Hash(),
    const Pred& comp = Pred(),
    const Alloc& al = Alloc());

The first constructor specifies a copy of the sequence controlled by right. The second constructor specifies an empty controlled sequence. The third constructor inserts the sequence of element values [first, last).

All constructors also initialize several stored values. For the copy constructor, the values are obtained from right. Otherwise:

Types
unordered_map::allocator_type

typedef Alloc allocator_type;

The type is a synonym for the template parameter Alloc.

unordered_map::const_iterator

typedef T1 const_iterator;

The type describes an object that can serve as a constant forward iterator for the controlled sequence. It is described here as a synonym for the implementation-defined type T1.

unordered_map::const_local_iterator
typedef T5 const_local_iterator;

The type describes an object that can serve as a constant forward iterator for a bucket. It is described here as a synonym for the implementation-defined type T5.

unordered_map::const_pointer

typedef Alloc::const_pointer const_pointer;

The type describes an object that can serve as a constant pointer to an element of the controlled sequence.

unordered_map::const_reference

typedef Alloc::const_reference const_reference;

The type describes an object that can serve as a constant reference to an element of the controlled sequence.

unordered_map::difference_type

typedef T3 difference_type;

The signed integer type describes an object that can represent the difference between the addresses of any two elements in the controlled sequence. It is described here as a synonym for the implementation-defined type T3.

unordered_map::hasher
typedef Hash hasher;

The type is a synonym for the template parameter Hash.

unordered_map::iterator

typedef T0 iterator;

The type describes an object that can serve as a forward iterator for the controlled sequence. It is described here as a synonym for the implementation-defined type T0.

unordered_map::key_equal
typedef Pred key_equal;

The type is a synonym for the template parameter Pred.

unordered_map::key_type

typedef Key key_type;

The type is a synonym for the template parameter Key.

unordered_map::local_iterator
typedef T4 local_iterator;

The type describes an object that can serve as a constant forward iterator for a bucket. It is described here as a synonym for the implementation-defined type T4.

unordered_map::mapped_type

typedef Ty mapped_type;

The type is a synonym for the template parameter Ty.

unordered_map::pointer

typedef Alloc::pointer pointer;

The type describes an object that can serve as a pointer to an element of the controlled sequence.

unordered_map::reference

typedef Alloc::reference reference;

The type describes an object that can serve as a reference to an element of the controlled sequence.

unordered_map::size_type

typedef T2 size_type;

The unsigned integer type describes an object that can represent the length of any controlled sequence. It is described here as a synonym for the implementation-defined type T2.

unordered_map::value_type
typedef std::pair<const Key, Ty> value_type;

The type describes an element of the controlled sequence.

Member functions
unordered_map::begin
iterator begin();
    const_iterator begin() const;
    local_iterator begin(size_type nbucket);
    const_local_iterator begin(size_type nbucket) const;

The first two member functions return a forward iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). The last two member functions return a forward iterator that points at the first element of bucket nbucket (or just beyond the end of an empty bucket).

unordered_map::bucket
    size_type bucket(const Key& keyval) const;

The member function returns the bucket number currently corresponding to the key value keyval.

unordered_map::bucket_count
    size_type bucket_count() const;

The member function returns the current number of buckets.

unordered_map::bucket_size
    size_type bucket_size(size_type nbucket) const;

The member function returns the size of bucket number nbucket.

unordered_map::clear

void clear();

The member function calls erase( begin(), end()).

unordered_map::count
size_type count(const Key& keyval) const;

The member function returns the number of elements in the range delimited by equal_range(keyval).

unordered_map::empty

bool empty() const;

The member function returns true for an empty controlled sequence.

unordered_map::end

iterator end();
    const_iterator end() const;
    local_iterator end(size_type nbucket);
    const_local_iterator end(size_type nbucket) const;

The first two member functions return a forward iterator that points just beyond the end of the sequence. The last two member functions return a forward iterator that points just beyond the end of bucket nbucket.

unordered_map::equal_range
std::pair<iterator, iterator>
    equal_range(const Key& keyval);
std::pair<const_iterator, const_iterator>
    equal_range(const Key& keyval) const;

The member function returns a pair of iterators X such that [X.first, X.second) delimits just those elements of the controlled sequence that have equivalent ordering with keyval. If no such elements exist, both iterators are end().

unordered_map::erase
iterator erase(iterator where);
iterator erase(iterator first, iterator last);
size_type erase(const Key& keyval);

The first member function removes the element of the controlled sequence pointed to by where. The second member function removes the elements in the range [first, last). Both return an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists.

The third member removes the elements in the range delimited by equal_range(keyval). It returns the number of elements it removes.

The member functions never throw an exception.

unordered_map::find
const_iterator find(const Key& keyval) const;

The member function returns equal_range(keyval).first.

unordered_map::get_allocator

Alloc get_allocator() const;

The member function returns the stored allocator object.

unordered_map::hash_function
  Hash hash_function() const;

The member function returns the stored hash function object.

unordered_map::insert
std::pair<iterator, bool> insert(const value_type& val);
iterator insert(iterator where, const value_type& val);
template<class InIt>
    void insert(InIt first, InIt last);

The first member function determines whether an element X exists in the sequence whose key has equivalent ordering to that of val. If not, it creates such an element X and initializes it with val. The function then determines the iterator where that designates X. If an insertion occurred, the function returns std::pair(where, true). Otherwise, it returns std::pair(where, false).

The second member function returns insert(val).first, using where as a starting place within the controlled sequence to search for the insertion point. (Insertion can possibly occur somewhat faster, if the insertion point immediately precedes or follows where.) The third member function inserts the sequence of element values, for each where in the range [first, last), by calling insert(*where).

If an exception is thrown during the insertion of a single element, the container is left unaltered and the exception is rethrown. If an exception is thrown during the insertion of multiple elements, the container is left in a stable but unspecified state and the exception is rethrown.

unordered_map::key_eq
    Pred key_eq() const;

The member function returns the stored comparison function object.

unordered_map::load_factor
    float load_factor() const;

The member function returns (float)size() / (float)bucket_count(), the average number of elements per bucket.

unordered_map::max_bucket_count
    size_type max_bucket_count() const;

The member function returns the maximum number of buckets currently permitted.

unordered_map::max_load_factor
    float max_load_factor() const;
    void max_load_factor(float factor);

The first member function returns the stored maximum load factor. The second member function replaces the stored maximum load factor with factor.

unordered_map::max_size

size_type max_size() const;

The member function returns the length of the longest sequence that the object can control.

unordered_map::operator[]
Ty& operator[](const Key& keyval);

The member function determines the iterator where as the return value of insert( value_type(keyval, Ty()). (It inserts an element with the specified key if no such element exists.) It then returns a reference to (*where).second.

unordered_map::rehash
    void rehash(size_type nbuckets);

The member function alters the number of buckets to be at least nbuckets and rebuilds the hash table as needed.

unordered_map::size

size_type size() const;

The member function returns the length of the controlled sequence.

unordered_map::swap

void swap(unordered_map& right);

The member function swaps the controlled sequences between *this and right. If get_allocator() == right.get_allocator(), it does so in constant time, it throws an exception only as a result of copying the stored traits object of typeTr, and it invalidates no references, pointers, or iterators that designate elements in the two controlled sequences. Otherwise, it performs a number of element assignments and constructor calls proportional to the number of elements in the two controlled sequences.

unordered_multimap

Description
Synopsis
Constructor
unordered_multimap::unordered_multimap
Types
unordered_multimap::allocator_type
unordered_multimap::const_iterator
unordered_multimap::const_local_iterator
unordered_multimap::const_pointer
unordered_multimap::const_reference
unordered_multimap::difference_type
unordered_multimap::hasher
unordered_multimap::iterator
unordered_multimap::key_equal
unordered_multimap::key_type
unordered_multimap::local_iterator
unordered_multimap::mapped_type
unordered_multimap::pointer
unordered_multimap::reference
unordered_multimap::size_type
unordered_multimap::value_type
Member functions
unordered_multimap::begin
unordered_multimap::bucket
unordered_multimap::bucket_count
unordered_multimap::bucket_size
unordered_multimap::clear
unordered_multimap::count
unordered_multimap::empty
unordered_multimap::end
unordered_multimap::equal_range
unordered_multimap::erase
unordered_multimap::find
unordered_multimap::get_allocator
unordered_multimap::hash_function
unordered_multimap::insert
unordered_multimap::key_eq
unordered_multimap::load_factor
unordered_multimap::max_bucket_count
unordered_multimap::max_load_factor
unordered_multimap::max_size
unordered_multimap::rehash
unordered_multimap::size
unordered_multimap::swap
Description

The template class describes an object that controls a varying-length sequence of elements of type std::pair<const Key, Ty>. The sequence is weakly ordered by a hash function, which partitions the sequence into an ordered set of subsequences called buckets. Within each bucket a comparison function determines whether any pair of elements has equivalent ordering. Each element stores two objects, a sort key and a value. The sequence is represented in a way that permits lookup, insertion, and removal of an arbitrary element with a number of operations that can be independent of the number of elements in the sequence (constant time), at least when all buckets are of roughly equal length. In the worst case, when all of the elements are in one bucket, the number of operations is proportional to the number of elements in the sequence (linear time). Moreover, inserting an element invalidates no iterators, and removing an element invalidates only those iterators which point at the removed element.

The object orders the sequence it controls by calling two stored objects, a comparison function object of type key_equal and a hash function object of type hasher. You access the first stored object by calling the member function key_eq(); and you access the second stored object by calling the member function hash_function(). Specifically, for all values X and Y of type Key, the call key_eq()(X, Y) returns true only if the two argument values have equivalent ordering; the call hash_function()(keyval) yields a distribution of values of type size_t. Unlike template class unordered_map, an object of template class unordered_multimap does not ensure that key_eq()(X, Y) is always false for any two elements of the controlled sequence. (Keys need not be unique.)

The object also stores a maximum load factor, which specifies the maximum desired average number of elements per bucket. If inserting an element causes load_factor() to exceed the maximum load factor, the container increases the number of buckets and rebuilds the hash table as needed.

The actual order of elements in the controlled sequence depends on the hash function, the comparison function, the order of insertion, the maximum load factor, and the current number of buckets. You cannot in general predict the order of elements in the controlled sequence. You can always be assured, however, that any subset of elements that have equivalent ordering are adjacent in the controlled sequence.

The object allocates and frees storage for the sequence it controls through a stored allocator object of type allocator_type. Such an allocator object must have the same external interface as an object of template class allocator. Note that the stored allocator object is not copied when the container object is assigned.

Synopsis
template <class Key,
    class Ty,
    class Hash  = std::tr1::hash<Key>,
    class Pred  = std::equal_to<Key>,
    class Alloc= std::allocator<Key> >
    class unordered_multimap {
public:
    typedef Key key_type;    
    typedef Ty mapped_type;
    typedef std::pair<const Key, Ty> value_type;
    typedef Hash hasher;
    typedef Pred key_equal;
    typedef Alloc allocator_type;

    typedef Alloc::pointer pointer;
    typedef Alloc::const_pointer const_pointer;
    typedef Alloc::reference reference;
    typedef Alloc::const_reference const_reference;

    typedef T0 iterator;
    typedef T1 const_iterator;
    typedef T2 size_type;
    typedef T3 difference_type;        
    typedef T4 local_iterator;
    typedef T5 const_local_iterator;

    unordered_multimap(
        const unordered_multimap& right);
    explicit unordered_multimap(
        size_type nbuckets = N0,
        const Hash& hfn = Hash(),
        const Pred& comp = Pred(),
        const Alloc& al = Alloc());
    template <class InIt>
        unordered_multimap(
        InIt first, InIt last,        
        size_type nbuckets = N0,
        const Hash& hfn = Hash(),
        const Pred& comp = Pred(),
        const Alloc& al = Alloc());
    
    iterator begin();
    const_iterator begin() const;
    local_iterator begin(size_type nbucket);
    const_local_iterator begin(size_type nbucket) const;

    iterator end();
    const_iterator end() const;
    local_iterator end(size_type nbucket);
    const_local_iterator end(size_type nbucket) const;

    size_type size() const;
    size_type max_size() const;
    bool empty() const;

    size_type bucket_count() const;
    size_type max_bucket_count() const;
    size_type bucket(const Key& keyval) const;
    size_type bucket_size(size_type nbucket) const;
    
    Hash hash_function() const;
    Pred key_eq() const;
    Alloc get_allocator() const;

    float load_factor() const;
    float max_load_factor() const;
    void max_load_factor(float factor);
    void rehash(size_type nbuckets);

    iterator insert(const value_type& val);
    iterator insert(iterator where, const value_type& val);
    template<class InIt>
        void insert(InIt first, InIt last);

    iterator erase(iterator where);
    iterator erase(iterator first, iterator last);
    size_type erase(const Key& keyval);
    void clear();

    void swap(unordered_multimap& right);

    const_iterator find(const Key& keyval) const;
    size_type count(const Key& keyval) const;
    std::pair<iterator, iterator>
        equal_range(const Key& keyval);
    std::pair<const_iterator, const_iterator>
        equal_range(const Key& keyval) const;
    };
Constructor
unordered_multimap::unordered_multimap
unordered_multimap(
    const unordered_multimap& right);
explicit unordered_multimap(
        size_type nbuckets = N0,
        const Hash& hfn = Hash(),
        const Pred& comp = Pred(),
        const Alloc& al = Alloc());
template <class InIt>
        unordered_multimap(
        InIt first, InIt last,        
        size_type nbuckets = N0,
        const Hash& hfn = Hash(),
        const Pred& comp = Pred(),
        const Alloc& al = Alloc());

The first constructor specifies a copy of the sequence controlled by right. The second constructor specifies an empty controlled sequence. The third constructor inserts the sequence of element values [first, last).

All constructors also initialize several stored values. For the copy constructor, the values are obtained from right. Otherwise:

Types
unordered_multimap::allocator_type

typedef Alloc allocator_type;

The type is a synonym for the template parameter Alloc.

unordered_multimap::const_iterator

typedef T1 const_iterator;

The type describes an object that can serve as a constant forward iterator for the controlled sequence. It is described here as a synonym for the implementation-defined type T1.

unordered_multimap::const_local_iterator
typedef T5 const_local_iterator;

The type describes an object that can serve as a constant forward iterator for a bucket. It is described here as a synonym for the implementation-defined type T5.

unordered_multimap::const_pointer

typedef Alloc::const_pointer const_pointer;

The type describes an object that can serve as a constant pointer to an element of the controlled sequence.

unordered_multimap::const_reference

typedef Alloc ::const_reference const_reference;

The type describes an object that can serve as a constant reference to an element of the controlled sequence.

unordered_multimap::difference_type

typedef T3 difference_type;

The signed integer type describes an object that can represent the difference between the addresses of any two elements in the controlled sequence. It is described here as a synonym for the implementation-defined type T3.

unordered_multimap::hasher
typedef Hash hasher;

The type is a synonym for the template parameter Hash.

unordered_multimap::iterator

typedef T0 iterator;

The type describes an object that can serve as a forward iterator for the controlled sequence. It is described here as a synonym for the implementation-defined type T0.

unordered_multimap::key_equal
typedef Pred key_equal;

The type is a synonym for the template parameter Pred.

unordered_multimap::key_type

typedef Key key_type;

The type is a synonym for the template parameter Key.

unordered_multimap::local_iterator
typedef T4 local_iterator;

The type describes an object that can serve as a constant forward iterator for a bucket. It is described here as a synonym for the implementation-defined type T4.

unordered_multimap::mapped_type

typedef Ty mapped_type;

The type is a synonym for the template parameter Ty.

unordered_multimap::pointer

typedef Alloc::pointer pointer;

The type describes an object that can serve as a pointer to an element of the controlled sequence.

unordered_multimap::reference

typedef Alloc::reference reference;

The type describes an object that can serve as a reference to an element of the controlled sequence.

unordered_multimap::size_type

typedef T2 size_type;

The unsigned integer type describes an object that can represent the length of any controlled sequence. It is described here as a synonym for the implementation-defined type T2.

unordered_multimap::value_type
typedef std::pair<const Key, Ty> value_type;

The type describes an element of the controlled sequence.

Member functions
unordered_multimap::begin
iterator begin();
    const_iterator begin() const;
    local_iterator begin(size_type nbucket);
    const_local_iterator begin(size_type nbucket) const;

The first two member functions return a forward iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). The last two member functions return a forward iterator that points at the first element of bucket nbucket (or just beyond the end of an empty bucket).

unordered_multimap::bucket
    size_type bucket(const Key& keyval) const;

The member function returns the bucket number currently corresponding to the key value keyval.

unordered_multimap::bucket_count
    size_type bucket_count() const;

The member function returns the current number of buckets.

unordered_multimap::bucket_size
    size_type bucket_size(size_type nbucket) const;

The member functions returns the size of bucket number nbucket.

unordered_multimap::clear

void clear();

The member function calls erase( begin(), end()).

unordered_multimap::count
size_type count(const Key& keyval) const;

The member function returns the number of elements in the range delimited by equal_range(keyval).

unordered_multimap::empty

bool empty() const;

The member function returns true for an empty controlled sequence.

unordered_multimap::end
iterator end();
    const_iterator end() const;
    local_iterator end(size_type nbucket);
    const_local_iterator end(size_type nbucket) const;

The first two member functions return a forward iterator that points just beyond the end of the sequence. The last two member functions return a forward iterator that points just beyond the end of bucket nbucket.

unordered_multimap::equal_range
std::pair<iterator, iterator>
  equal_range(const Key& keyval);
std::pair<const_iterator, const_iterator>
  equal_range(const Key& keyval) const;

The member function returns a pair of iterators X such that [X.first, X.second) delimits just those elements of the controlled sequence that have equivalent ordering with keyval. If no such elements exist, both iterators are end().

unordered_multimap::erase
    iterator erase(iterator where);
    iterator erase(iterator first, iterator last);
    sizetype erase(const Key& keyval);

The first member function removes the element of the controlled sequence pointed to by where. The second member function removes the elements in the range [first, last). Both return an iterator that designates the first element remaining beyond any elements removed, or end() if no such element exists.

The third member removes the elements in the range delimited by equal_range(keyval). It returns the number of elements it removes.

The member functions never throw an exception.

unordered_multimap::find
const_iterator find(const Key& keyval) const;

The member function returns equal_range(keyval).first.

unordered_multimap::get_allocator

Alloc get_allocator() const;

The member function returns the stored allocator object.

unordered_multimap::hash_function
  Hash hash_function() const;

The member function returns the stored hash function object.

unordered_multimap::insert
iterator insert(const value_type& val);
iterator insert(iterator where, const value_type& val);
template <class InIt>
   void insert(InIt first, InIt last);

The first member function inserts the element val in the controlled sequence, then returns the iterator that designates the inserted element. The second member function returns insert(val), using where as a starting place within the controlled sequence to search for the insertion point. (Insertion can possibly occur somewhat faster, if the insertion point immediately precedes or follows where.) The third member function inserts the sequence of element values, for each where in the range [first, last), by calling insert(*where).

If an exception is thrown during the insertion of a single element, the container is left unaltered and the exception is rethrown. If an exception is thrown during the insertion of multiple elements, the container is left in a stable but unspecified state and the exception is rethrown.

unordered_multimap::key_eq
    Pred key_eq() const;

The member function returns the stored comparison function object.

unordered_multimap::load_factor
    float load_factor() const;

The member function returns (float)size() / (float)bucket_count(), the average number of elements per bucket.

unordered_multimap::max_bucket_count
    size_type max_bucket_count() const;

The member function returns the maximum number of buckets currently permitted.

unordered_multimap::max_load_factor
    float max_load_factor() const;
    void max_load_factor(float z);

The first member function returns the stored maximum load factor. The second member function replaces the stored maximum load factor with factor.

unordered_multimap::max_size

size_type max_size() const;

The member function returns the length of the longest sequence that the object can control.

unordered_multimap::rehash
    void rehash(size_type nbuckets);

The member function alters the number of buckets to be at least nbuckets and rebuilds the hash table as needed.

unordered_multimap::size

size_type size() const;

The member function returns the length of the controlled sequence.

unordered_multimap::swap

void swap(unordered_multimap& right);

The member function swaps the controlled sequences between *this and right. If get_allocator() == right.get_allocator(), it does so in constant time, it throws an exception only as a result of copying the stored function object of type Tr, and it invalidates no references, pointers, or iterators that designate elements in the two controlled sequences. Otherwise, it performs a number of element assignments and constructor calls proportional to the number of elements in the two controlled sequences.

Copyright note

Certain materials included or referred to in this document are copyright P.J. Plauger and/or Dinkumware, Ltd. or are based on materials that are copyright P.J. Plauger and/or Dinkumware, Ltd.

Notwithstanding the meta-data for this document, copyright information for this document is as follows:

Copyright © IBM Corp. 1999, 2010. & Copyright © P.J. Plauger and/or Dinkumware, Ltd. 1992-2006.