Standard C++ Library Reference ISO/IEC (VERSION3)
hash_compare(Pr pred);
size_t operator()(const Key& Key) const;
bool operator()(const Key& keyval1,
const Key& keyval2) 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 as a hash traits object to order the
sequence it controls. Each of these stores hash traits object of type Tr (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, Pr>, the following behavior is required by the above containers:
For all values keyval of type Key, the call hash_comp(keyval) serves as a hash
function, which yields a distribution of values of type size_t. The function supplied
by hash_compare simply returns keyval.
●
For any value keyval1 of type Key that precedes keyval2 in the sequence and has
the same hash value (value returned by the hash function), hash_comp(keyval2,
keyval1) is false. The function must impose a strict weak ordering on values of type
Key. The function supplied by hash_compare returns comp(keyval1,
keyval2) where comp is a stored object of type Pr that you can specify when you
construct the object hash_comp. For the default Pr parameter type less<Key>, sort
keys never decrease in value.
●
The integer constant 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.
●
The integer constant 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.
●
hash_map
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