|
|
hash_compare , hash_map , hash_multimap , operator== , operator!= , operator< , operator> , operator<= , operator>= , swap - defines template classes that implement hashed associative containers that map keys to values (standard template library)
namespace sco_std { template<class Key, class Bop> class hash_compare; template<class Key, class T, class Pred, class A> class hash_map; template<class Key, class T, class Pred, class A> class hash_multimap; // TEMPLATE FUNCTIONS template<class Key, class T, class Pred, class A> bool operator==( const hash_map<Key, T, Pred, A>& lhs, const hash_map<Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator==( const hash_multimap<Key, T, Pred, A>& lhs, const hash_multimap<Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator!=( const hash_map<Key, T, Pred, A>& lhs, const hash_map<Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator!=( const hash_multimap<Key, T, Pred, A>& lhs, const hash_multimap<Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator<( const hash_map<Key, T, Pred, A>& lhs, const hash_map<Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator<( const hash_multimap<Key, T, Pred, A>& lhs, const hash_multimap<Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator>( const hash_map<Key, T, Pred, A>& lhs, const hash_map<Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator>( const hash_multimap<Key, T, Pred, A>& lhs, const hash_multimap<Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator<=( const hash_map<Key, T, Pred, A>& lhs, const hash_map<Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator<=( const hash_multimap<Key, T, Pred, A>& lhs, const hash_multimap<Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator>=( const hash_map<Key, T, Pred, A>& lhs, const hash_map<Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator>=( const hash_multimap<Key, T, Pred, A>& lhs, const hash_multimap<Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> void swap( hash_map<Key, T, Pred, A>& lhs, hash_map<Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> void swap( hash_multimap<Key, T, Pred, A>& lhs, hash_multimap<Key, T, Pred, A>& rhs); };
Include the STL
standard header <hash_map>
to define the
container
template classes hash_map
and
hash_multimap
, and their supporting
templates.
template<class Key, class Bop = less<Key> > class hash_compare { Bop comp; public: const size_t bucket_size = 4; const size_t min_buckets = 8; hash_compare(); hash_compare(Bop parg); size_t operator()(const Key& Key) const; bool operator()(const Key& key1, const Key& key2) const; };
The template class describes an object that can be used by
any of the containers
hash_map
,
hash_multimap
,
hash_set
, or
hash_multiset
to order the sequence it controls.
Each of these stores a function object of type Bop
(a template parameter). You can derive a class from a specialization of
hash_compare
, to selectively override certain functions
and objects. Or you can supply your own version of this class,
provided you meet certain minimum requirements.
Specifically, for an object hash_comp
of type
hash_compare<Key, Bop>
,
the following behavior is required by the above containers:
key
of type Key
,
the call hash_comp(key)
serves as a
hash function,
which yields a distribution of values of type size_t
.
The function supplied by hash_compare
simply
returns key
.key1
of
type Key
that precedes key2
in the sequence
and has the same hash value (value returned by the hash function),
hash_comp(key2, key1)
is false. The function must impose a
total ordering
on values of type Key
.
The function supplied by hash_compare
returns
comp(key1, key2)
where comp
is a stored
object of type Bop
that you can specify when you construct
the object hash_comp
. For the default Bop
parameter type
less<Key>
,
sort keys never decrease in value.bucket_size
specifies the mean number of elements per ``bucket'' (hash-table
entry) that the container should endeavor not to exceed. It must
be greater than zero. The value supplied by
hash_compare
is 4.min_buckets
specifies the minimum number of buckets to maintain in the hash table.
It must be a power of two and greater than zero. The value supplied by
hash_compare
is 8.allocator_type , begin , clear , const_iterator , const_pointer , const_reference , const_reverse_iterator , count , difference_type , empty , end , equal_range , erase , find , get_allocator , insert , iterator , key_comp , key_compare , key_type , lower_bound , hash_map , mapped_type , max_size , operator[] , pointer , rbegin , reference , rend , reverse_iterator , size , size_type , swap , upper_bound , value_comp , value_compare , value_type
template<class Key, class T, class Pred = hash_compare<Key, less<Key> >, class A = allocator<pair<const Key, T> > > class hash_map { public: typedef Key key_type; typedef T mapped_type; typedef Pred key_compare; typedef A allocator_type; typedef pair<const Key, T> value_type; class value_compare; typedef A::pointer pointer; typedef A::const_pointer const_pointer; typedef A::reference reference; typedef A::const_reference const_reference; typedef T0 iterator; typedef T1 const_iterator; typedef T2 size_type; typedef T3 difference_type; typedef reverse_iterator<const_iterator> const_reverse_iterator; typedef reverse_iterator<iterator> reverse_iterator; hash_map(); explicit hash_map(const Pred& comp); hash_map(const Pred& comp, const A& al); hash_map(const hash_map& x); template<class InIt> hash_map(InIt first, InIt last); template<class InIt> hash_map(InIt first, InIt last, const Pred& comp); template<class InIt> hash_map(InIt first, InIt last, const Pred& comp, const A& al); iterator begin(); const_iterator begin() const; iterator end(); const_iterator end() const; reverse_iterator rbegin(); const_reverse_iterator rbegin() const; reverse_iterator rend(); const_reverse_iterator rend() const; size_type size() const; size_type max_size() const; bool empty() const; A get_allocator() const; mapped_type operator[](const Key& key); pair<iterator, bool> insert(const value_type& x); iterator insert(iterator it, const value_type& x); template<class InIt> void insert(InIt first, InIt last); iterator erase(iterator it); iterator erase(iterator first, iterator last); size_type erase(const Key& key); void clear(); void swap(hash_map& x); key_compare key_comp() const; value_compare value_comp() const; iterator find(const Key& key); const_iterator find(const Key& key) const; size_type count(const Key& key) const; iterator lower_bound(const Key& key); const_iterator lower_bound(const Key& key) const; iterator upper_bound(const Key& key); const_iterator upper_bound(const Key& key) const; pair<iterator, iterator> equal_range(const Key& key); pair<const_iterator, const_iterator> equal_range(const Key& key) const; };
The template class describes an object that controls a
varying-length sequence of elements of type
pair<const Key, T>
.
The sequence is
ordered by the function object
Pred
, which includes both a two-operand function for imposing a
total ordering
and a one-operand hash function.
The first element of each pair is the sort key and the
second is its associated 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).
In the worst case, 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 a
stored function object of type Pred
. You access
this stored object by calling the member function
key_comp()
.
Such a function object must behave the same as an object of class
hash_compare<Key, Bop>
.
Specifically, for all values key
of type Key
,
the call key_comp()(key)
yields a distribution
of values of type size_t
.
Moreover, class Bop
imposes a
total ordering
on sort keys of type Key
.
For any element x
that precedes
y
in the sequence and has the same hash value,
key_comp()(y.first,
x.first)
is false. (For the default function object
less<Key>
,
sort keys never decrease in value.)
Unlike template class hash_multimap
,
an object of template class hash_map
ensures that
key_comp()(x.first, y.first)
is true.
(Each key is unique.)
The actual order of elements in the controlled sequence depends on the hash function, the ordering function, and the current size of the hash table stored in the container object. You cannot determine the current size of the hash table, so you cannot in general predict the order of elements in the controlled sequence.
The object allocates and frees storage for the sequence it controls
through a stored allocator object
of class A
. 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.
typedef A allocator_type;
The type is a synonym for the template parameter A
.
const_iterator begin() const; iterator begin();
The member function returns a bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence).
void clear();
The member function calls
erase(
begin(),
end())
.
typedef T1 const_iterator;
The type describes an object that can serve as a constant
bidirectional iterator for the controlled sequence.
It is described here as a
synonym for the implementation-defined type T1
.
typedef A::const_pointer const_pointer;
The type describes an object that can serve as a constant pointer to an element of the controlled sequence.
typedef A::const_reference const_reference;
The type describes an object that can serve as a constant reference to an element of the controlled sequence.
typedef reverse_iterator<const_iterator> const_reverse_iterator;
The type describes an object that can serve as a constant reverse bidirectional iterator for the controlled sequence.
size_type count(const Key& key) const;
The member function returns the number of elements x
in the range
[lower_bound(key),
upper_bound(key)).
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
.
bool empty() const;
The member function returns true for an empty controlled sequence.
const_iterator end() const; iterator end();
The member function returns a bidirectional iterator that points just beyond the end of the sequence.
pair<iterator, iterator> equal_range(const Key& key); pair<const_iterator, const_iterator> equal_range(const Key& key) const;
The member function returns a pair of iterators x
such that x.first ==
lower_bound(key)
and x.second ==
upper_bound(key)
.
iterator erase(iterator it); iterator erase(iterator first, iterator last); size_type erase(const Key& key);
The first member function removes the element of the controlled
sequence pointed to by it
.
The second member function removes the elements
in the interval [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 function removes
the elements with sort keys in the range
[lower_bound(key),
upper_bound(key)).
It returns the number of elements it removes.
The member functions never throw an exception.
iterator find(const Key& key); const_iterator find(const Key& key) const;
The member function returns
lower_bound(key)
.
A get_allocator() const;
The member function returns the stored allocator object.
hash_map(); explicit hash_map(const Pred& comp); hash_map(const Pred& comp, const A& al); hash_map(const hash_map& x); template<class InIt> hash_map(InIt first, InIt last); template<class InIt> hash_map(InIt first, InIt last, const Pred& comp); template<class InIt> hash_map(InIt first, InIt last, const Pred& comp, const A& al);
All constructors store an
allocator object and
initialize the controlled sequence. The allocator object is the argument
al
, if present. For the copy constructor, it is
x.get_allocator()
.
Otherwise, it is A()
.
All constructors also store a function object that can later
be returned by calling
key_comp()
.
The function object is the argument comp
, if present.
For the copy constructor, it is
x.key_comp()
).
Otherwise, it is Pred()
.
The first three constructors specify an
empty initial controlled sequence. The fourth constructor specifies
a copy of the sequence controlled by x
.
The last three constructors specify the sequence of element values
[first, last)
.
pair<iterator, bool> insert(const value_type& x); iterator insert(iterator it, const value_type& x); template<class InIt> void insert(InIt first, InIt last);
The first member function determines whether an element y
exists in the sequence whose key has
equivalent ordering
to that of x
. If not, it creates such
an element y
and initializes it with x
.
The function then determines the iterator it
that
designates y
. If an insertion occurred, the function
returns pair(it, true)
.
Otherwise, it returns pair(it, false)
.
The second member function returns insert(x).first
,
using it
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 it
.)
The third member function
inserts the sequence of element values,
for each it
in the range [first, last)
,
by calling insert(*it)
.
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.
typedef T0 iterator;
The type describes an object that can serve as a bidirectional
iterator for the controlled sequence.
It is described here as a
synonym for the implementation-defined type T0
.
key_compare key_comp() const;
The member function returns the stored function object that determines the order of elements in the controlled sequence. In particular, the stored object defines the member function:
bool operator()(const Key& x, const Key& y);
which returns true if x
strictly
precedes y
in the sort order.
typedef Pred key_compare;
The type describes a function object that behaves much like an object of class
hash_compare<Key, Bop>
.
In particular, it can compare two
sort keys to determine the relative order of two
elements in the controlled sequence.
typedef Key key_type;
The type describes the sort key object stored in each element of the controlled sequence.
iterator lower_bound(const Key& key); const_iterator lower_bound(const Key& key) const;
The member function returns an iterator that designates the
earliest element x
in the controlled sequence
for which x.first
has
equivalent ordering
to key
.
If no such element exists, the function returns
end()
.
typedef T mapped_type;
The type is a synonym for the template parameter T
.
size_type max_size() const;
The member function returns the length of the longest sequence that the object can control.
T& operator[](const Key& key);
The member function determines the iterator it
as the return value of
insert(
value_type(key, T())
.
(It inserts an element with the specified key if no such element
exists.) It then returns a reference to
(*it).second
.
typedef A::pointer pointer;
The type describes an object that can serve as a pointer to an element of the controlled sequence.
const_reverse_iterator rbegin() const; reverse_iterator rbegin();
The member function returns a reverse bidirectional iterator that points just beyond the end of the controlled sequence. Hence, it designates the beginning of the reverse sequence.
typedef A::reference reference;
The type describes an object that can serve as a reference to an element of the controlled sequence.
const_reverse_iterator rend() const; reverse_iterator rend();
The member function returns a reverse bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). Hence, it designates the end of the reverse sequence.
typedef reverse_iterator<iterator> reverse_iterator;
The type describes an object that can serve as a reverse bidirectional iterator for the controlled sequence.
size_type size() const;
The member function returns the length of the controlled sequence.
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
.
void swap(hash_map& x);
The member function swaps the controlled sequences between
*this
and x
. If
get_allocator()
== x.get_allocator()
, it does so in constant time,
it throws an exception only as a result of copying the stored
function object of type Pred
, 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.
iterator upper_bound(const Key& key); const_iterator upper_bound(const Key& key) const;
The member function returns an iterator
just beyond the iterator that designates the
latest element x
in the controlled sequence
for which x.first
has
equivalent ordering
to key
.
If no such element exists, the function returns
end()
.
value_compare value_comp() const;
The member function returns a function object that determines the order of elements in the controlled sequence.
class value_compare : public binary_function<value_type, value_type, bool> { public: bool operator()(const value_type& x, const value_type& y) const {return (comp(x.first, y.first)); } protected: value_compare(key_compare pr) : comp(pr) {} key_compare comp; };
The type describes a function object that can compare the
sort keys in two elements to determine their relative order
in the controlled sequence. The function object stores an object
comp
of type key_type
.
The member function operator()
uses this
object to compare the sort-key components of two element.
typedef pair<const Key, T> value_type;
The type describes an element of the controlled sequence.
allocator_type , begin , clear , const_iterator , const_pointer , const_reference , const_reverse_iterator , count , difference_type , empty , end , equal_range , erase , find , get_allocator , insert , iterator , key_comp , key_compare , key_type , lower_bound , mapped_type , max_size , hash_multimap , rbegin , reference , rend , reverse_iterator , size , size_type , swap , upper_bound , value_comp , value_compare , value_type
template<class Key, class T, class Pred = hash_compare<Key, less<Key> >, class A = allocator<pair<const Key, T> > > class hash_multimap { public: typedef Key key_type; typedef T mapped_type; typedef Pred key_compare; typedef A allocator_type; typedef pair<const Key, T> value_type; class value_compare; typedef A::reference reference; typedef A::const_reference const_reference; typedef T0 iterator; typedef T1 const_iterator; typedef T2 size_type; typedef T3 difference_type; typedef reverse_iterator<const_iterator> const_reverse_iterator; typedef reverse_iterator<iterator> reverse_iterator; hash_multimap(); explicit hash_multimap(const Pred& comp); hash_multimap(const Pred& comp, const A& al); hash_multimap(const hash_multimap& x); template<class InIt> hash_multimap(InIt first, InIt last); template<class InIt> hash_multimap(InIt first, InIt last, const Pred& comp); template<class InIt> hash_multimap(InIt first, InIt last, const Pred& comp, const A& al); iterator begin(); const_iterator begin() const; iterator end(); const_iterator end() const; reverse_iterator rbegin(); const_reverse_iterator rbegin() const; reverse_iterator rend(); const_reverse_iterator rend() const; size_type size() const; size_type max_size() const; bool empty() const; A get_allocator() const; iterator insert(const value_type& x); iterator insert(iterator it, const value_type& x); template<class InIt> void insert(InIt first, InIt last); iterator erase(iterator it); iterator erase(iterator first, iterator last); size_type erase(const Key& key); void clear(); void swap(hash_multimap& x); key_compare key_comp() const; value_compare value_comp() const; iterator find(const Key& key); const_iterator find(const Key& key) const; size_type count(const Key& key) const; iterator lower_bound(const Key& key); const_iterator lower_bound(const Key& key) const; iterator upper_bound(const Key& key); const_iterator upper_bound(const Key& key) const; pair<iterator, iterator> equal_range(const Key& key); pair<const_iterator, const_iterator> equal_range(const Key& key) const; };
The template class describes an object that controls a
varying-length sequence of elements of type
pair<const Key, T>
.
The sequence is
ordered by the function object
Pred
, which includes both a two-operand function for imposing a
total ordering
and a one-operand hash function.
The first element of each pair is the sort key and the
second is its associated 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).
In the worst case, 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 a
stored function object of type Pred
. You access
this stored object by calling the member function
key_comp()
.
Such a function object must behave the same as an object of class
hash_compare<Key, Bop>
.
Specifically, for all values key
of type Key
,
the call key_comp()(key)
yields a distribution
of values of type size_t
.
Moreover, class Bop
imposes a
total ordering
on sort keys of type Key
.
For any element x
that precedes
y
in the sequence and has the same hash value,
key_comp()(y.first,
x.first)
is false. (For the default function object
less<Key>
,
sort keys never decrease in value.)
Unlike template class hash_map
,
an object of template class hash_multimap
does not ensure that
key_comp()(x.first, y.first)
is true.
(Keys need not be unique.)
The actual order of elements in the controlled sequence depends on the hash function, the ordering function, and the current size of the hash table stored in the container object. You cannot determine the current size of the hash table, so 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 class A
. 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.
typedef A allocator_type;
The type is a synonym for the template parameter A
.
const_iterator begin() const; iterator begin();
The member function returns a bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence).
void clear();
The member function calls
erase(
begin(),
end())
.
typedef T1 const_iterator;
The type describes an object that can serve as a constant
bidirectional iterator for the controlled sequence.
It is described here as a
synonym for the implementation-defined type T1
.
typedef A::const_pointer const_pointer;
The type describes an object that can serve as a constant pointer to an element of the controlled sequence.
typedef A::const_reference const_reference;
The type describes an object that can serve as a constant reference to an element of the controlled sequence.
typedef reverse_iterator<const_iterator> const_reverse_iterator;
The type describes an object that can serve as a constant reverse bidirectional iterator for the controlled sequence.
size_type count(const Key& key) const;
The member function returns the number of elements x
in the range
[lower_bound(key),
upper_bound(key)).
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
.
bool empty() const;
The member function returns true for an empty controlled sequence.
const_iterator end() const; iterator end();
The member function returns a bidirectional iterator that points just beyond the end of the sequence.
pair<iterator, iterator> equal_range(const Key& key); pair<const_iterator, const_iterator> equal_range(const Key& key) const;
The member function returns a pair of iterators x
such that x.first ==
lower_bound(key)
and x.second ==
upper_bound(key)
.
iterator erase(iterator it); iterator erase(iterator first, iterator last); size_type erase(const Key& key);
The first member function removes the element of the controlled
sequence pointed to by it
.
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 with sort keys in the range
[lower_bound(key),
upper_bound(key)).
It returns the number of elements it removes.
The member functions never throw an exception.
iterator find(const Key& key); const_iterator find(const Key& key) const;
The member function returns
lower_bound(key)
.
A get_allocator() const;
The member function returns the stored allocator object.
hash_multimap(); explicit hash_multimap(const Pred& comp); hash_multimap(const Pred& comp, const A& al); hash_multimap(const hash_multimap& x); template<class InIt> hash_multimap(InIt first, InIt last); template<class InIt> hash_multimap(InIt first, InIt last, const Pred& comp); template<class InIt> hash_multimap(InIt first, InIt last, const Pred& comp, const A& al);
All constructors store an
allocator object and
initialize the controlled sequence. The allocator object is the argument
al
, if present. For the copy constructor, it is
x.get_allocator()
.
Otherwise, it is A()
.
All constructors also store a function object that can later
be returned by calling
key_comp()
.
The function object is the argument comp
, if present.
For the copy constructor, it is
x.key_comp()
).
Otherwise, it is Pred()
.
The first three constructors specify an
empty initial controlled sequence. The fourth constructor specifies
a copy of the sequence controlled by x
.
The last three constructors specify the sequence of element values
[first, last)
.
iterator insert(const value_type& x); iterator insert(iterator it, const value_type& x); template<class InIt> void insert(InIt first, InIt last);
The first member function inserts the element x
in the controlled sequence, then returns
the iterator that designates the inserted element.
The second member function returns insert(x)
,
using it
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 it
.)
The third member function
inserts the sequence of element values,
for each it
in the range [first, last)
,
by calling insert(*it)
.
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.
typedef T0 iterator;
The type describes an object that can serve as a bidirectional
iterator for the controlled sequence.
It is described here as a
synonym for the implementation-defined type T0
.
key_compare key_comp() const;
The member function returns the stored function object that determines the order of elements in the controlled sequence. In particular, the stored object defines the member function:
bool operator()(const Key& x, const Key& y);
which returns true if x
strictly
precedes y
in the sort order.
typedef Pred key_compare;
The type describes a function object that behaves much like an object of class
hash_compare<Key, Bop>
.
In particular, it can compare two
sort keys to determine the relative order of two
elements in the controlled sequence.
typedef Key key_type;
The type describes the sort key object stored in each element of the controlled sequence.
iterator lower_bound(const Key& key); const_iterator lower_bound(const Key& key) const;
The member function returns an iterator that designates the
earliest element x
in the controlled sequence for which
key_comp()(x.
first, key)
is
false.
end()
.
typedef T mapped_type;
The type is a synonym for the template parameter T
.
size_type max_size() const;
The member function returns the length of the longest sequence that the object can control.
typedef A::pointer pointer;
The type describes an object that can serve as a pointer to an element of the controlled sequence.
const_reverse_iterator rbegin() const; reverse_iterator rbegin();
The member function returns a reverse bidirectional iterator that points just beyond the end of the controlled sequence. Hence, it designates the beginning of the reverse sequence.
typedef A::reference reference;
The type describes an object that can serve as a reference to an element of the controlled sequence.
const_reverse_iterator rend() const; reverse_iterator rend();
The member function returns a reverse bidirectional iterator that points at the first element of the sequence (or just beyond the end of an empty sequence). Hence, it designates the end of the reverse sequence.
typedef reverse_iterator<iterator> reverse_iterator;
The type describes an object that can serve as a reverse bidirectional iterator for the controlled sequence.
size_type size() const;
The member function returns the length of the controlled sequence.
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
.
void swap(hash_multimap& x);
The member function swaps the controlled sequences between
*this
and x
. If
get_allocator()
== x.get_allocator()
, it does so in constant time,
it throws an exception only as a result of copying the stored
function object of type Pred
, 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.
iterator upper_bound(const Key& key); const_iterator upper_bound(const Key& key) const;
The member function returns an iterator
just beyond the iterator that designates the
latest element x
in the controlled sequence
for which x.first
has
equivalent ordering
to key
.
If no such element exists, the function returns
end()
.
value_compare value_comp() const;
The member function returns a function object that determines the order of elements in the controlled sequence.
class value_compare : public binary_function<value_type, value_type, bool> { public: bool operator()(const value_type& x, const value_type& y) const {return (comp(x.first, x.second)); } protected: value_compare(key_compare pr) : comp(pr) {} key_compare comp; };
The type describes a function object that can compare the
sort keys in two elements to determine their relative order
in the controlled sequence. The function object stores an object
comp
of type key_type
.
The member function operator()
uses this
object to compare the sort-key components of two element.
typedef pair<const Key, T> value_type;
The type describes an element of the controlled sequence.
template<class Key, class T, class Pred, class A> bool operator!=( const hash_map <Key, T, Pred, A>& lhs, const hash_map <Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator!=( const hash_multimap <Key, T, Pred, A>& lhs, const hash_multimap <Key, T, Pred, A>& rhs);
The template function returns !(lhs == rhs)
.
template<class Key, class T, class Pred, class A> bool operator==( const hash_map <Key, T, Pred, A>& lhs, const hash_map <Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator==( const hash_multimap <Key, T, Pred, A>& lhs, const hash_multimap <Key, T, Pred, A>& rhs);
The first template function overloads operator==
to compare two objects of template class
hash_map
.
The second template function overloads operator==
to compare two objects of template class
hash_multimap
.
Both functions return
lhs.size() == rhs.size() &&
equal(lhs.
begin(), lhs.
end(), rhs.begin())
.
template<class Key, class T, class Pred, class A> bool operator<( const hash_map <Key, T, Pred, A>& lhs, const hash_map <Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator<( const hash_multimap <Key, T, Pred, A>& lhs, const hash_multimap <Key, T, Pred, A>& rhs);
The first template function overloads operator<
to compare two objects of template class
hash_map
.
The second template function overloads operator<
to compare two objects of template class
hash_multimap
.
Both functions return
lexicographical_compare(lhs.
begin(), lhs.
end(), rhs.begin(), rhs.end(),
lhs.value_comp())
.
template<class Key, class T, class Pred, class A> bool operator<=( const hash_map <Key, T, Pred, A>& lhs, const hash_map <Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator<=( const hash_multimap <Key, T, Pred, A>& lhs, const hash_multimap <Key, T, Pred, A>& rhs);
The template function returns !(rhs < lhs)
.
template<class Key, class T, class Pred, class A> bool operator>( const hash_map <Key, T, Pred, A>& lhs, const hash_map <Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator>( const hash_multimap <Key, T, Pred, A>& lhs, const hash_multimap <Key, T, Pred, A>& rhs);
The template function returns rhs < lhs
.
template<class Key, class T, class Pred, class A> bool operator>=( const hash_map <Key, T, Pred, A>& lhs, const hash_map <Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> bool operator!=( const hash_multimap <Key, T, Pred, A>& lhs, const hash_multimap <Key, T, Pred, A>& rhs);
The template function returns !(lhs < rhs)
.
template<class Key, class T, class Pred, class A> void swap( hash_map <Key, T, Pred, A>& lhs, hash_map <Key, T, Pred, A>& rhs); template<class Key, class T, class Pred, class A> void swap( hash_multimap <Key, T, Pred, A>& lhs, hash_multimap <Key, T, Pred, A>& rhs);
The template function executes
lhs.swap(rhs)
.
Copyright © 1992-1996 by P.J. Plauger. Portions derived from work copyright © 1994 by Hewlett-Packard Company. All rights reserved.