<hash_set>

<hash_set>


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

namespace std {
template<class Key, class Tr, class Alloc>
    class hash_set;
template<class Key, class Tr, class Alloc>
    class hash_multiset;

        // TEMPLATE FUNCTIONS
template<class Key, class Tr, class Alloc>
    bool operator==(
        const hash_set<Key, Tr, Alloc>& left,
        const hash_set<Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator==(
        const hash_multiset<Key, Tr, Alloc>& left,
        const hash_multiset<Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator!=(
        const hash_set<Key, Tr, Alloc>& left,
        const hash_set<Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator!=(
        const hash_multiset<Key, Tr, Alloc>& left,
        const hash_multiset<Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator<(
        const hash_set<Key, Tr, Alloc>& left,
        const hash_set<Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator<(
        const hash_multiset<Key, Tr, Alloc>& left,
        const hash_multiset<Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator>(
        const hash_set<Key, Tr, Alloc>& left,
        const hash_set<Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator>(
        const hash_multiset<Key, Tr, Alloc>& left,
        const hash_multiset<Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator<=(
        const hash_set<Key, Tr, Alloc>& left,
        const hash_set<Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator<=(
        const hash_multiset<Key, Tr, Alloc>& left,
        const hash_multiset<Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator>=(
        const hash_set<Key, Tr, Alloc>& left,
        const hash_set<Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator>=(
        const hash_multiset<Key, Tr, Alloc>& left,
        const hash_multiset<Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    void swap(
        hash_set<Key, Tr, Alloc>& left,
        hash_set<Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    void swap(
        hash_multiset<Key, Tr, Alloc>& left,
        hash_multiset<Key, Tr, Alloc>& right);
}  // namespace std

hash_multiset


allocator_type · begin · bucket · bucket_count · bucket_size · clear · const_iterator · const_local_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 · load_factor · local_iterator · lower_bound · max_bucket_count · max_load_factor · max_size · hash_multiset · pointer · rbegin · reference · rehash · rend · reverse_iterator · size · size_type · swap · upper_bound · value_comp · value_compare · value_type


template<class Key,
    class Tr = hash_compare<Key, less<Key> >,
    class Alloc = allocator<Key> >
    class hash_multiset {
public:
    typedef Key key_type;
    typedef Tr key_compare;
    typedef Key value_type;
    typedef Tr value_compare;
    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;
    typedef reverse_iterator<const_iterator>
        const_reverse_iterator;
    typedef reverse_iterator<iterator> reverse_iterator;

    hash_multiset();
    explicit hash_multiset(const Tr& traits);
    hash_multiset(const Tr& traits, const Alloc& al);
    hash_multiset(const hash_multiset& right);
    template<class InIt>
        hash_multiset(InIt first, InIt last);
    template<class InIt>
        hash_multiset(InIt first, InIt last,
            const Tr& traits);
    template<class InIt>
        hash_multiset(InIt first, InIt last,
            const Tr& traits, const Alloc& al);

    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;

    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;

    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;

    key_compare key_comp() const;
    value_compare value_comp() 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(hash_multiset& right);

    const_iterator find(const Key& keyval) const;
    size_type count(const Key& keyval) const;
    iterator lower_bound(const Key& keyval);
    const_iterator lower_bound(const Key& keyval) const;
    iterator upper_bound(const Key& keyval);
    const_iterator upper_bound(const Key& keyval) const;
    pair<iterator, iterator>
        equal_range(const Key& keyval);
    pair<const_iterator, const_iterator>
        equal_range(const Key& keyval) const;
    };

The template class describes an object that controls a varying-length sequence of elements of type const Key. The sequence is ordered by the hash traits object Tr, which includes two functions:

  • a one-operand hash function, which partitions the sequence into an ordered set of subsequences called buckets.
  • a two-operand comparison function for imposing a strict weak ordering within each bucket.

Each element serves as both 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 a stored hash traits object of type Tr. You access this stored object by calling the member function key_comp(). Such a traits object must behave the same as an object of class hash_compare<Key, Pr>. Specifically, for all values keyval of type Key, the call Tr(keyval) yields a distribution of values of type size_t. Moreover, class Tr imposes a strict weak 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, X) is false. (For the default function object less<Key>, sort keys never decrease in value.) Unlike template class hash_set, an object of template class hash_multiset does not ensure that key_comp()(X, Y) is true. (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 class Alloc. 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.

hash_multiset::allocator_type

typedef Alloc allocator_type;

The type is a synonym for the template parameter Alloc.

hash_multiset::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).

hash_multiset::bucket

size_type bucket(const Key& keyval) const;

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

hash_multiset::bucket_count

size_type bucket_count() const;

The member function returns the current number of buckets.

hash_multiset::bucket_size

size_type bucket_size(size_type nbucket) const;

The member functions returns the size of bucket number nbucket.

hash_multiset::clear

void clear();

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

hash_multiset::const_iterator

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.

hash_multiset::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.

hash_multiset::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.

hash_multiset::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.

hash_multiset::const_reverse_iterator

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.

hash_multiset::count

size_type count(const Key& keyval) const;

The member function returns the number of elements in the range [lower_bound(keyval), upper_bound(keyval)).

hash_multiset::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.

hash_multiset::empty

bool empty() const;

The member function returns true for an empty controlled sequence.

hash_multiset::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.

hash_multiset::equal_range

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

The member function returns a pair of iterators X such that X.first == lower_bound(keyval) and X.second == upper_bound(keyval).

hash_multiset::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 with sort keys in the range [lower_bound(keyval), upper_bound(keyval)). It returns the number of elements it removes.

The member functions never throw an exception.

hash_multiset::find

const_iterator find(const Key& keyval) const;

The member function returns lower_bound(keyval).

hash_multiset::get_allocator

Alloc get_allocator() const;

The member function returns the stored allocator object.

hash_multiset::hash_multiset

hash_multiset();
explicit hash_multiset(const Tr& traits);
hash_multiset(const Tr& traits, const Alloc& al);
hash_multiset(const hash_multiset& right);
template<class InIt>
    hash_multiset(InIt first, InIt last);
template<class InIt>
    hash_multiset(InIt first, InIt last,
        const Tr& traits);
template<class InIt>
    hash_multiset(InIt first, InIt last,
        const Tr& traits, const Alloc& 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 right.get_allocator(). Otherwise, it is Alloc().

All constructors also store a hash traits object that can later be returned by calling key_comp(). The hash traits object is the argument traits, if present. For the copy constructor, it is right.key_comp()). Otherwise, it is Tr().

The first three constructors specify an empty initial controlled sequence. The fourth constructor specifies a copy of the sequence controlled by right. The last three constructors specify the sequence of element values [first, last).

hash_multiset::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.

hash_multiset::iterator

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.

hash_multiset::key_comp

key_compare key_comp() const;

The member function returns the stored hash traits object that determines the order of elements in the controlled sequence. In particular, the stored object defines the member function:

bool operator()(const Key& left, const Key& right);

which returns true if left strictly precedes right in the sort order.

hash_multiset::key_compare

typedef Tr key_compare;

The type describes a traits object that behaves much like an object of class hash_compare<Key, Pr>. In particular, it can compare two sort keys to determine the relative order of two elements in the controlled sequence.

hash_multiset::key_type

typedef Key key_type;

The type describes the sort key object which constitutes each element of the controlled sequence.

hash_multiset::load_factor

float load_factor() const;

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

hash_multiset::local_iterator

typedef T4 local_iterator;

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

hash_multiset::lower_bound

iterator lower_bound(const Key& keyval);
const_iterator lower_bound(const Key& keyval) const;

The member function returns an iterator that designates the earliest element X in the controlled sequence for which X has equivalent ordering to keyval, as well as the same hash value. (This is generally uninteresting, except that the interval [lower_bound(keyval), upper_bound(keyval)) does delimit all elements with equivalent ordering to keyval.) If no such element exists, the function returns end().

hash_multiset::max_bucket_count

size_type max_bucket_count() const;

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

hash_multiset::max_load_factort

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.

hash_multiset::max_size

size_type max_size() const;

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

hash_multiset::pointer

typedef Alloc::pointer pointer;

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

hash_multiset::rbegin

reverse_iterator rbegin();
const_reverse_iterator rbegin() const;

The member functions return a reverse bidirectional iterator that points just beyond the end of the controlled sequence. Hence, it designates the beginning of the reverse sequence.

hash_multiset::reference

typedef Alloc::reference reference;

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

hash_multiset::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.

hash_multiset::rend

reverse_iterator rend();
const_reverse_iterator rend() const;

The member functions return 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.

hash_multiset::reverse_iterator

typedef reverse_iterator<iterator> reverse_iterator;

The type describes an object that can serve as a reverse bidirectional iterator for the controlled sequence.

hash_multiset::size

size_type size() const;

The member function returns the length of the controlled sequence.

hash_multiset::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.

hash_multiset::swap

void swap(hash_multiset& 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 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.

hash_multiset::upper_bound

iterator upper_bound(const Key& keyval);
const_iterator upper_bound(const Key& keyval) const;

The member function returns an iterator just beyond the iterator that designates the latest element X in the controlled sequence for which X has equivalent ordering to keyval. If no such element exists, the function returns end().

hash_multiset::value_comp

value_compare value_comp() const;

The member function returns a function object that determines the order of elements in the controlled sequence.

hash_multiset::value_compare

typedef Tr value_compare;

The type describes a function object that can compare two elements as sort keys to determine their relative order in the controlled sequence.

hash_multiset::value_type

typedef Key value_type;

The type describes an element of the controlled sequence.

hash_set


allocator_type · begin · bucket · bucket_count · bucket_size · clear · const_iterator · const_local_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 · load_factor · local_iterator · lower_bound · max_bucket_count · max_load_factor · max_size · hash_set · pointer · rbegin · reference · rehash · rend · reverse_iterator · size · size_type · swap · upper_bound · value_comp · value_compare · value_type


template<class Key,
    class Tr = hash_compare<Key, less<Key> >,
    class Alloc = allocator<Key> >
    class hash_set {
public:
    typedef Key key_type;
    typedef Tr key_compare;
    typedef Key value_type;
    typedef Tr value_compare;
    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;
    typedef reverse_iterator<const_iterator>
        const_reverse_iterator;
    typedef reverse_iterator<iterator> reverse_iterator;

    hash_set();
    explicit hash_set(const Tr& traits);
    hash_set(const Tr& traits, const Alloc& al);
    hash_set(const hash_set& right);
    template<class InIt>
        hash_set(InIt first, InIt last);
    template<class InIt>
        hash_set(InIt first, InIt last,
            const Tr& traits);
    template<class InIt>
        hash_set(InIt first, InIt last,
            const Tr& traits, const Alloc& al);

    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;

    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;

    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;

    key_compare key_comp() const;
    value_compare value_comp() 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(hash_set& right);

    const_iterator find(const Key& keyval) const;
    size_type count(const Key& keyval) const;
    iterator lower_bound(const Key& keyval);
    const_iterator lower_bound(const Key& keyval) const;
    iterator upper_bound(const Key& keyval);
    const_iterator upper_bound(const Key& keyval) const;
    pair<iterator, iterator>
        equal_range(const Key& keyval);
    pair<const_iterator, const_iterator>
        equal_range(const Key& keyval) const;
    };

The template class describes an object that controls a varying-length sequence of elements of type const Key. The sequence is ordered by the hash traits object Tr, which includes two functions:

  • a one-operand hash function, which partitions the sequence into an ordered set of subsequences called buckets.
  • a two-operand comparison function for imposing a strict weak ordering within each bucket.

Each element serves as both 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 a stored hash traits object of type Tr. You access this stored object by calling the member function key_comp(). Such a traits object must behave the same as an object of class hash_compare<Key, Pr>. Specifically, for all values keyval of type Key, the call Tr(keyval) yields a distribution of values of type size_t. Moreover, class Tr imposes a strict weak 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, X) is false. (For the default function object less<Key>, sort keys never decrease in value.) Unlike template class hash_multiset, an object of template class hash_set ensures that key_comp()(X, Y) is true. (Each key is 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 class Alloc. 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.

hash_set::allocator_type

typedef Alloc allocator_type;

The type is a synonym for the template parameter Alloc.

hash_set::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).

hash_set::bucket

size_type bucket(const Key& keyval) const;

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

hash_set::bucket_count

size_type bucket_count() const;

The member function returns the current number of buckets.

hash_set::bucket_size

size_type bucket_size(size_type nbucket) const;

The member functions returns the size of bucket number nbucket.

hash_set::clear

void clear();

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

hash_set::const_iterator

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.

hash_set::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.

hash_set::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.

hash_set::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.

hash_set::const_reverse_iterator

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.

hash_set::count

size_type count(const Key& keyval) const;

The member function returns the number of elements in the range [lower_bound(keyval), upper_bound(keyval)).

hash_set::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.

hash_set::empty

bool empty() const;

The member function returns true for an empty controlled sequence.

hash_set::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.

hash_set::equal_range

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

The member function returns a pair of iterators X such that X.first == lower_bound(keyval) and X.second == upper_bound(keyval).

hash_set::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 with sort keys in the range [lower_bound(keyval), upper_bound(keyval)). It returns the number of elements it removes.

The member functions never throw an exception.

hash_set::find

const_iterator find(const Key& keyval) const;

The member function returns lower_bound(keyval).

hash_set::get_allocator

Alloc get_allocator() const;

The member function returns the stored allocator object.

hash_set::hash_set

hash_set();
explicit hash_set(const Tr& traits);
hash_set(const Tr& traits, const Alloc& al);
hash_set(const hash_set& right);
template<class InIt>
    hash_set(InIt first, InIt last);
template<class InIt>
    hash_set(InIt first, InIt last,
        const Tr& traits);
template<class InIt>
    hash_set(InIt first, InIt last,
        const Tr& traits, const Alloc& 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 right.get_allocator(). Otherwise, it is Alloc().

All constructors also store a hash traits object that can later be returned by calling key_comp(). The hash traits object is the argument traits, if present. For the copy constructor, it is right.key_comp()). Otherwise, it is Tr().

The first three constructors specify an empty initial controlled sequence. The fourth constructor specifies a copy of the sequence controlled by right. The last three constructors specify the sequence of element values [first, last).

hash_set::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.

hash_set::iterator

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.

hash_set::key_comp

key_compare key_comp() const;

The member function returns the stored hash traits object that determines the order of elements in the controlled sequence. In particular, the stored object defines the member function:

bool operator()(const Key& left, const Key& right);

which returns true if left strictly precedes right in the sort order.

hash_set::key_compare

typedef Tr key_compare;

The type describes a traits object that behaves much like an object of class hash_compare<Key, Pr>. In particular, it can compare two sort keys to determine the relative order of two elements in the controlled sequence.

hash_set::key_type

typedef Key key_type;

The type describes the sort key object which constitutes each element of the controlled sequence.

hash_set::load_factor

float load_factor() const;

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

hash_set::local_iterator

typedef T4 local_iterator;

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

hash_set::lower_bound

iterator lower_bound(const Key& keyval);
const_iterator lower_bound(const Key& keyval) const;

The member function returns an iterator that designates the earliest element X in the controlled sequence for which X has equivalent ordering to keyval, as well as the same hash value. (This is generally uninteresting, except that the interval [lower_bound(keyval), upper_bound(keyval)) does delimit all elements with equivalent ordering to keyval.) If no such element exists, the function returns end().

hash_set::max_bucket_count

size_type max_bucket_count() const;

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

hash_set::max_load_factort

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.

hash_set::max_size

size_type max_size() const;

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

hash_set::pointer

typedef Alloc::pointer pointer;

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

hash_set::rbegin

reverse_iterator rbegin();
const_reverse_iterator rbegin() const;

The member functions return a reverse bidirectional iterator that points just beyond the end of the controlled sequence. Hence, it designates the beginning of the reverse sequence.

hash_set::reference

typedef Alloc::reference reference;

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

hash_set::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.

hash_set::rend

reverse_iterator rend();
const_reverse_iterator rend() const;

The member functions return 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.

hash_set::reverse_iterator

typedef reverse_iterator<iterator> reverse_iterator;

The type describes an object that can serve as a reverse bidirectional iterator for the controlled sequence.

hash_set::size

size_type size() const;

The member function returns the length of the controlled sequence.

hash_set::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.

hash_set::swap

void swap(hash_set& 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 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.

hash_set::upper_bound

iterator upper_bound(const Key& keyval);
const_iterator upper_bound(const Key& keyval) const;

The member function returns an iterator just beyond the iterator that designates the latest element X in the controlled sequence for which X has equivalent ordering to keyval. If no such element exists, the function returns end().

hash_set::value_comp

value_compare value_comp() const;

The member function returns a function object that determines the order of elements in the controlled sequence.

hash_set::value_compare

typedef Tr value_compare;

The type describes a function object that can compare two elements as sort keys to determine their relative order in the controlled sequence.

hash_set::value_type

typedef Key value_type;

The type describes an element of the controlled sequence.

swap

template<class Key, class Tr, class Alloc>
    void swap(
        hash_multiset <Key, Tr, Alloc>& left,
        hash_multiset <Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    void swap(
        hash_set <Key, Tr, Alloc>& left,
        hash_set <Key, Tr, Alloc>& right);

The template function executes left.swap(right).

operator!=

template<class Key, class Tr, class Alloc>
    bool operator!=(
        const hash_set <Key, Tr, Alloc>& left,
        const hash_set <Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator!=(
        const hash_multiset <Key, Tr, Alloc>& left,
        const hash_multiset <Key, Tr, Alloc>& right);

The template function returns !(left == right).

operator==

template<class Key, class Tr, class Alloc>
    bool operator==(
        const hash_set <Key, Tr, Alloc>& left,
        const hash_set <Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator==(
        const hash_multiset <Key, Tr, Alloc>& left,
        const hash_multiset <Key, Tr, Alloc>& right);

The first template function overloads operator== to compare two objects of template class hash_set. The second template function overloads operator== to compare two objects of template class hash_multiset. Both functions return left.size() == right.size() && equal(left. begin(), left. end(), right.begin()).

operator<

template<class Key, class Tr, class Alloc>
    bool operator<(
        const hash_set <Key, Tr, Alloc>& left,
        const hash_set <Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator<(
        const hash_multiset <Key, Tr, Alloc>& left,
        const hash_multiset <Key, Tr, Alloc>& right);

The first template function overloads operator< to compare two objects of template class hash_set. The second template function overloads operator< to compare two objects of template class hash_multiset. Both functions return lexicographical_compare(left. begin(), left. end(), right.begin(), right.end(), left.value_comp()).

operator<=

template<class Key, class Tr, class Alloc>
    bool operator<=(
        const hash_set <Key, Tr, Alloc>& left,
        const hash_set <Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator<=(
        const hash_multiset <Key, Tr, Alloc>& left,
        const hash_multiset <Key, Tr, Alloc>& right);

The template function returns !(right < left).

operator>

template<class Key, class Tr, class Alloc>
    bool operator>(
        const hash_set <Key, Tr, Alloc>& left,
        const hash_set <Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator>(
        const hash_multiset <Key, Tr, Alloc>& left,
        const hash_multiset <Key, Tr, Alloc>& right);

The template function returns right < left.

operator>=

template<class Key, class Tr, class Alloc>
    bool operator>=(
        const hash_set <Key, Tr, Alloc>& left,
        const hash_set <Key, Tr, Alloc>& right);
template<class Key, class Tr, class Alloc>
    bool operator>=(
        const hash_multiset <Key, Tr, Alloc>& left,
        const hash_multiset <Key, Tr, Alloc>& right);

The template function returns !(left < right).


See also the Table of Contents and the Index.

Copyright © 1992-2006 by P.J. Plauger. All rights reserved.

Last modified: 2013-12-21



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus