STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
unordered_set.h File Reference

Go to the source code of this file.

Functions

namespace std _GLIBCXX_VISIBILITY (default)
 

Detailed Description

This is an internal header file, included by other library headers. Do not attempt to use it directly. {unordered_set}

Function Documentation

namespace std _GLIBCXX_VISIBILITY ( default  )

Base types for unordered_set.

Base types for unordered_multiset.

A standard container composed of unique keys (containing at most one of each key value) in which the elements' keys are the elements themselves.

Template Parameters
_ValueType of key objects.
_HashHashing function object type, defaults to hash<_Value>.
_PredPredicate function object type, defaults to equal_to<_Value>.
_AllocAllocator type, defaults to allocator<_Key>.

Meets the requirements of a container, and unordered associative container

Base is _Hashtable, dispatched at compile time via template alias __uset_hashtable.

Public typedefs.

Iterator-related typedefs.

Default constructor creates no elements.

Parameters
__nInitial number of buckets.
__hfA hash functor.
__eqlA key equality functor.
__aAn allocator object.

Builds an unordered_set from a range.

Parameters
__firstAn input iterator.
__lastAn input iterator.
__nMinimal initial number of buckets.
__hfA hash functor.
__eqlA key equality functor.
__aAn allocator object.

Create an unordered_set consisting of copies of the elements from [__first,__last). This is linear in N (where N is distance(__first,__last)).

Copy constructor.

Move constructor.

Builds an unordered_set from an initializer_list.

Parameters
__lAn initializer_list.
__nMinimal initial number of buckets.
__hfA hash functor.
__eqlA key equality functor.
__aAn allocator object.

Create an unordered_set consisting of copies of the elements in the list. This is linear in N (where N is __l.size()).

Copy assignment operator.

Move assignment operator.

Unordered_set list assignment operator.

Parameters
__lAn initializer_list.

This function fills an unordered_set with copies of the elements in the initializer list __l.

Note that the assignment completely changes the unordered_set and that the resulting unordered_set's size is the same as the number of elements assigned. Old data may be lost.

Returns the allocator object with which the unordered_set was constructed.

Returns true if the unordered_set is empty.

Returns the size of the unordered_set.

Returns the maximum size of the unordered_set.

Returns a read-only (constant) iterator that points to the first element in the unordered_set.

Returns a read-only (constant) iterator that points one past the last element in the unordered_set.

Returns a read-only (constant) iterator that points to the first element in the unordered_set.

Returns a read-only (constant) iterator that points one past the last element in the unordered_set.

Attempts to build and insert an element into the unordered_set.

Parameters
__argsArguments used to generate an element.
Returns
A pair, of which the first element is an iterator that points to the possibly inserted element, and the second is a bool that is true if the element was actually inserted.

This function attempts to build and insert an element into the unordered_set. An unordered_set relies on unique keys and thus an element is only inserted if it is not already present in the unordered_set.

Insertion requires amortized constant time.

Attempts to insert an element into the unordered_set.

Parameters
__posAn iterator that serves as a hint as to where the element should be inserted.
__argsArguments used to generate the element to be inserted.
Returns
An iterator that points to the element with key equivalent to the one generated from __args (may or may not be the element itself).

This function is not concerned about whether the insertion took place, and thus does not return a boolean like the single-argument emplace() does. Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.

For more on hinting, see: http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html

Insertion requires amortized constant time.

Attempts to insert an element into the unordered_set.

Parameters
__xElement to be inserted.
Returns
A pair, of which the first element is an iterator that points to the possibly inserted element, and the second is a bool that is true if the element was actually inserted.

This function attempts to insert an element into the unordered_set. An unordered_set relies on unique keys and thus an element is only inserted if it is not already present in the unordered_set.

Insertion requires amortized constant time.

Attempts to insert an element into the unordered_set.

Parameters
__hintAn iterator that serves as a hint as to where the element should be inserted.
__xElement to be inserted.
Returns
An iterator that points to the element with key of __x (may or may not be the element passed in).

This function is not concerned about whether the insertion took place, and thus does not return a boolean like the single-argument insert() does. Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.

For more on hinting, see: http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html

Insertion requires amortized constant.

A template function that attempts to insert a range of elements.

Parameters
__firstIterator pointing to the start of the range to be inserted.
__lastIterator pointing to the end of the range.

Complexity similar to that of the range constructor.

Attempts to insert a list of elements into the unordered_set.

Parameters
__lA std::initializer_list<value_type> of elements to be inserted.

Complexity similar to that of the range constructor.

Erases an element from an unordered_set.

Parameters
__positionAn iterator pointing to the element to be erased.
Returns
An iterator pointing to the element immediately following __position prior to the element being erased. If no such element exists, end() is returned.

This function erases an element, pointed to by the given iterator, from an unordered_set. Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Erases elements according to the provided key.

Parameters
__xKey of element to be erased.
Returns
The number of elements erased.

This function erases all the elements located by the given key from an unordered_set. For an unordered_set the result of this function can only be 0 (not present) or 1 (present). Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Erases a [__first,__last) range of elements from an unordered_set.

Parameters
__firstIterator pointing to the start of the range to be erased.
__lastIterator pointing to the end of the range to be erased.
Returns
The iterator __last.

This function erases a sequence of elements from an unordered_set. Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Erases all elements in an unordered_set. Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Swaps data with another unordered_set.

Parameters
__xAn unordered_set of the same element and allocator types.

This exchanges the elements between two sets in constant time. Note that the global std::swap() function is specialized such that std::swap(s1,s2) will feed to this function.

Returns the hash functor object with which the unordered_set was constructed.

Returns the key comparison object with which the unordered_set was constructed.

Tries to locate an element in an unordered_set.

Parameters
__xElement to be located.
Returns
Iterator pointing to sought-after element, or end() if not found.

This function takes a key and tries to locate the element with which the key matches. If successful the function returns an iterator pointing to the sought after element. If unsuccessful it returns the past-the-end ( end() ) iterator.

Finds the number of elements.

Parameters
__xElement to located.
Returns
Number of elements with specified key.

This function only makes sense for unordered_multisets; for unordered_set the result will either be 0 (not present) or 1 (present).

Finds a subsequence matching given key.

Parameters
__xKey to be located.
Returns
Pair of iterators that possibly points to the subsequence matching given key.

This function probably only makes sense for multisets.

Returns the number of buckets of the unordered_set.

Returns the maximum number of buckets of the unordered_set.

Returns a read-only (constant) iterator pointing to the first bucket element.

Parameters
__nThe bucket index.
Returns
A read-only local iterator.

Returns a read-only (constant) iterator pointing to one past the last bucket elements.

Parameters
__nThe bucket index.
Returns
A read-only local iterator.

Returns the average number of elements per bucket.

Returns a positive number that the unordered_set tries to keep the load factor less than or equal to.

Change the unordered_set maximum load factor.

Parameters
__zThe new maximum load factor.

May rehash the unordered_set.

Parameters
__nThe new number of buckets.

Rehash will occur only if the new number of buckets respect the unordered_set maximum load factor.

Prepare the unordered_set for a specified number of elements.

Parameters
__nNumber of elements required.

Same as rehash(ceil(n / max_load_factor())).

A standard container composed of equivalent keys (possibly containing multiple of each key value) in which the elements' keys are the elements themselves.

Template Parameters
_ValueType of key objects.
_HashHashing function object type, defaults to hash<_Value>.
_PredPredicate function object type, defaults to equal_to<_Value>.
_AllocAllocator type, defaults to allocator<_Key>.

Meets the requirements of a container, and unordered associative container

Base is _Hashtable, dispatched at compile time via template alias __umset_hashtable.

Public typedefs.

Iterator-related typedefs.

Default constructor creates no elements.

Parameters
__nInitial number of buckets.
__hfA hash functor.
__eqlA key equality functor.
__aAn allocator object.

Builds an unordered_multiset from a range.

Parameters
__firstAn input iterator.
__lastAn input iterator.
__nMinimal initial number of buckets.
__hfA hash functor.
__eqlA key equality functor.
__aAn allocator object.

Create an unordered_multiset consisting of copies of the elements from [__first,__last). This is linear in N (where N is distance(__first,__last)).

Copy constructor.

Move constructor.

Builds an unordered_multiset from an initializer_list.

Parameters
__lAn initializer_list.
__nMinimal initial number of buckets.
__hfA hash functor.
__eqlA key equality functor.
__aAn allocator object.

Create an unordered_multiset consisting of copies of the elements in the list. This is linear in N (where N is __l.size()).

Copy assignment operator.

Move assignment operator.

Unordered_multiset list assignment operator.

Parameters
__lAn initializer_list.

This function fills an unordered_multiset with copies of the elements in the initializer list __l.

Note that the assignment completely changes the unordered_multiset and that the resulting unordered_set's size is the same as the number of elements assigned. Old data may be lost.

Returns the allocator object with which the unordered_multiset was constructed.

Returns true if the unordered_multiset is empty.

Returns the size of the unordered_multiset.

Returns the maximum size of the unordered_multiset.

Returns a read-only (constant) iterator that points to the first element in the unordered_multiset.

Returns a read-only (constant) iterator that points one past the last element in the unordered_multiset.

Returns a read-only (constant) iterator that points to the first element in the unordered_multiset.

Returns a read-only (constant) iterator that points one past the last element in the unordered_multiset.

Builds and insert an element into the unordered_multiset.

Parameters
__argsArguments used to generate an element.
Returns
An iterator that points to the inserted element.

Insertion requires amortized constant time.

Inserts an element into the unordered_multiset.

Parameters
__posAn iterator that serves as a hint as to where the element should be inserted.
__argsArguments used to generate the element to be inserted.
Returns
An iterator that points to the inserted element.

Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.

For more on hinting, see: http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html

Insertion requires amortized constant time.

Inserts an element into the unordered_multiset.

Parameters
__xElement to be inserted.
Returns
An iterator that points to the inserted element.

Insertion requires amortized constant time.

Inserts an element into the unordered_multiset.

Parameters
__hintAn iterator that serves as a hint as to where the element should be inserted.
__xElement to be inserted.
Returns
An iterator that points to the inserted element.

Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.

For more on hinting, see: http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html

Insertion requires amortized constant.

A template function that inserts a range of elements.

Parameters
__firstIterator pointing to the start of the range to be inserted.
__lastIterator pointing to the end of the range.

Complexity similar to that of the range constructor.

Inserts a list of elements into the unordered_multiset.

Parameters
__lA std::initializer_list<value_type> of elements to be inserted.

Complexity similar to that of the range constructor.

Erases an element from an unordered_multiset.

Parameters
__positionAn iterator pointing to the element to be erased.
Returns
An iterator pointing to the element immediately following __position prior to the element being erased. If no such element exists, end() is returned.

This function erases an element, pointed to by the given iterator, from an unordered_multiset.

Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Erases elements according to the provided key.

Parameters
__xKey of element to be erased.
Returns
The number of elements erased.

This function erases all the elements located by the given key from an unordered_multiset.

Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Erases a [__first,__last) range of elements from an unordered_multiset.

Parameters
__firstIterator pointing to the start of the range to be erased.
__lastIterator pointing to the end of the range to be erased.
Returns
The iterator __last.

This function erases a sequence of elements from an unordered_multiset.

Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Erases all elements in an unordered_multiset.

Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.

Swaps data with another unordered_multiset.

Parameters
__xAn unordered_multiset of the same element and allocator types.

This exchanges the elements between two sets in constant time. Note that the global std::swap() function is specialized such that std::swap(s1,s2) will feed to this function.

Returns the hash functor object with which the unordered_multiset was constructed.

Returns the key comparison object with which the unordered_multiset was constructed.

Tries to locate an element in an unordered_multiset.

Parameters
__xElement to be located.
Returns
Iterator pointing to sought-after element, or end() if not found.

This function takes a key and tries to locate the element with which the key matches. If successful the function returns an iterator pointing to the sought after element. If unsuccessful it returns the past-the-end ( end() ) iterator.

Finds the number of elements.

Parameters
__xElement to located.
Returns
Number of elements with specified key.

Finds a subsequence matching given key.

Parameters
__xKey to be located.
Returns
Pair of iterators that possibly points to the subsequence matching given key.

Returns the number of buckets of the unordered_multiset.

Returns the maximum number of buckets of the unordered_multiset.

Returns a read-only (constant) iterator pointing to the first bucket element.

Parameters
__nThe bucket index.
Returns
A read-only local iterator.

Returns a read-only (constant) iterator pointing to one past the last bucket elements.

Parameters
__nThe bucket index.
Returns
A read-only local iterator.

Returns the average number of elements per bucket.

Returns a positive number that the unordered_multiset tries to keep the load factor less than or equal to.

Change the unordered_multiset maximum load factor.

Parameters
__zThe new maximum load factor.

May rehash the unordered_multiset.

Parameters
__nThe new number of buckets.

Rehash will occur only if the new number of buckets respect the unordered_multiset maximum load factor.

Prepare the unordered_multiset for a specified number of elements.

Parameters
__nNumber of elements required.

Same as rehash(ceil(n / max_load_factor())).

34 {
35 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
36 
38  template<bool _Cache>
39  using __uset_traits = __detail::_Hashtable_traits<_Cache, true, true>;
40 
41  template<typename _Value,
42  typename _Hash = hash<_Value>,
43  typename _Pred = std::equal_to<_Value>,
44  typename _Alloc = std::allocator<_Value>,
45  typename _Tr = __uset_traits<__cache_default<_Value, _Hash>::value>>
46  using __uset_hashtable = _Hashtable<_Value, _Value, _Alloc,
47  __detail::_Identity, _Pred, _Hash,
48  __detail::_Mod_range_hashing,
49  __detail::_Default_ranged_hash,
50  __detail::_Prime_rehash_policy, _Tr>;
51 
53  template<bool _Cache>
54  using __umset_traits = __detail::_Hashtable_traits<_Cache, true, false>;
55 
56  template<typename _Value,
57  typename _Hash = hash<_Value>,
58  typename _Pred = std::equal_to<_Value>,
59  typename _Alloc = std::allocator<_Value>,
60  typename _Tr = __umset_traits<__cache_default<_Value, _Hash>::value>>
61  using __umset_hashtable = _Hashtable<_Value, _Value, _Alloc,
62  __detail::_Identity,
63  _Pred, _Hash,
64  __detail::_Mod_range_hashing,
65  __detail::_Default_ranged_hash,
66  __detail::_Prime_rehash_policy, _Tr>;
67 
89  template<class _Value,
90  class _Hash = hash<_Value>,
91  class _Pred = std::equal_to<_Value>,
92  class _Alloc = std::allocator<_Value> >
93  class unordered_set : __check_copy_constructible<_Alloc>
94  {
95  typedef __uset_hashtable<_Value, _Hash, _Pred, _Alloc> _Hashtable;
96  _Hashtable _M_h;
97 
98  public:
99  // typedefs:
101  typedef typename _Hashtable::key_type key_type;
103  typedef typename _Hashtable::value_type value_type;
104  typedef typename _Hashtable::hasher hasher;
105  typedef typename _Hashtable::key_equal key_equal;
106  typedef typename _Hashtable::allocator_type allocator_type;
108 
110  typedef typename allocator_type::pointer pointer;
112  typedef typename allocator_type::const_pointer const_pointer;
113  typedef typename allocator_type::reference reference;
114  typedef typename allocator_type::const_reference const_reference;
115  typedef typename _Hashtable::iterator iterator;
116  typedef typename _Hashtable::const_iterator const_iterator;
117  typedef typename _Hashtable::local_iterator local_iterator;
118  typedef typename _Hashtable::const_local_iterator const_local_iterator;
119  typedef typename _Hashtable::size_type size_type;
120  typedef typename _Hashtable::difference_type difference_type;
122 
123  // construct/destroy/copy
131  explicit
132  unordered_set(size_type __n = 10,
133  const hasher& __hf = hasher(),
134  const key_equal& __eql = key_equal(),
135  const allocator_type& __a = allocator_type())
136  : _M_h(__n, __hf, __eql, __a)
137  { }
138 
152  template<typename _InputIterator>
153  unordered_set(_InputIterator __f, _InputIterator __l,
154  size_type __n = 0,
155  const hasher& __hf = hasher(),
156  const key_equal& __eql = key_equal(),
157  const allocator_type& __a = allocator_type())
158  : _M_h(__f, __l, __n, __hf, __eql, __a)
159  { }
160 
162  unordered_set(const unordered_set&) = default;
163 
165  unordered_set(unordered_set&&) = default;
166 
178  unordered_set(initializer_list<value_type> __l,
179  size_type __n = 0,
180  const hasher& __hf = hasher(),
181  const key_equal& __eql = key_equal(),
182  const allocator_type& __a = allocator_type())
183  : _M_h(__l, __n, __hf, __eql, __a)
184  { }
185 
187  unordered_set&
188  operator=(const unordered_set&) = default;
189 
191  unordered_set&
192  operator=(unordered_set&&) = default;
193 
205  unordered_set&
206  operator=(initializer_list<value_type> __l)
207  {
208  _M_h = __l;
209  return *this;
210  }
211 
214  allocator_type
215  get_allocator() const noexcept
216  { return _M_h.get_allocator(); }
217 
218  // size and capacity:
219 
221  bool
222  empty() const noexcept
223  { return _M_h.empty(); }
224 
226  size_type
227  size() const noexcept
228  { return _M_h.size(); }
229 
231  size_type
232  max_size() const noexcept
233  { return _M_h.max_size(); }
234 
235  // iterators.
236 
238 
242  iterator
243  begin() noexcept
244  { return _M_h.begin(); }
245 
246  const_iterator
247  begin() const noexcept
248  { return _M_h.begin(); }
250 
252 
256  iterator
257  end() noexcept
258  { return _M_h.end(); }
259 
260  const_iterator
261  end() const noexcept
262  { return _M_h.end(); }
264 
269  const_iterator
270  cbegin() const noexcept
271  { return _M_h.begin(); }
272 
277  const_iterator
278  cend() const noexcept
279  { return _M_h.end(); }
280 
281  // modifiers.
282 
298  template<typename... _Args>
299  std::pair<iterator, bool>
300  emplace(_Args&&... __args)
301  { return _M_h.emplace(std::forward<_Args>(__args)...); }
302 
324  template<typename... _Args>
325  iterator
326  emplace_hint(const_iterator __pos, _Args&&... __args)
327  { return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
328 
330 
343  std::pair<iterator, bool>
344  insert(const value_type& __x)
345  { return _M_h.insert(__x); }
346 
347  std::pair<iterator, bool>
348  insert(value_type&& __x)
349  { return _M_h.insert(std::move(__x)); }
351 
353 
372  iterator
373  insert(const_iterator __hint, const value_type& __x)
374  { return _M_h.insert(__hint, __x); }
375 
376  iterator
377  insert(const_iterator __hint, value_type&& __x)
378  { return _M_h.insert(__hint, std::move(__x)); }
380 
390  template<typename _InputIterator>
391  void
392  insert(_InputIterator __first, _InputIterator __last)
393  { _M_h.insert(__first, __last); }
394 
402  void
403  insert(initializer_list<value_type> __l)
404  { _M_h.insert(__l); }
405 
407 
420  iterator
421  erase(const_iterator __position)
422  { return _M_h.erase(__position); }
423 
424  // LWG 2059.
425  iterator
426  erase(iterator __it)
427  { return _M_h.erase(__it); }
429 
442  size_type
443  erase(const key_type& __x)
444  { return _M_h.erase(__x); }
445 
460  iterator
461  erase(const_iterator __first, const_iterator __last)
462  { return _M_h.erase(__first, __last); }
463 
470  void
471  clear() noexcept
472  { _M_h.clear(); }
473 
483  void
484  swap(unordered_set& __x)
485  { _M_h.swap(__x._M_h); }
486 
487  // observers.
488 
491  hasher
492  hash_function() const
493  { return _M_h.hash_function(); }
494 
497  key_equal
498  key_eq() const
499  { return _M_h.key_eq(); }
500 
501  // lookup.
502 
504 
515  iterator
516  find(const key_type& __x)
517  { return _M_h.find(__x); }
518 
519  const_iterator
520  find(const key_type& __x) const
521  { return _M_h.find(__x); }
523 
533  size_type
534  count(const key_type& __x) const
535  { return _M_h.count(__x); }
536 
538 
546  std::pair<iterator, iterator>
547  equal_range(const key_type& __x)
548  { return _M_h.equal_range(__x); }
549 
550  std::pair<const_iterator, const_iterator>
551  equal_range(const key_type& __x) const
552  { return _M_h.equal_range(__x); }
554 
555  // bucket interface.
556 
558  size_type
559  bucket_count() const noexcept
560  { return _M_h.bucket_count(); }
561 
563  size_type
564  max_bucket_count() const noexcept
565  { return _M_h.max_bucket_count(); }
566 
567  /*
568  * @brief Returns the number of elements in a given bucket.
569  * @param __n A bucket index.
570  * @return The number of elements in the bucket.
571  */
572  size_type
573  bucket_size(size_type __n) const
574  { return _M_h.bucket_size(__n); }
575 
576  /*
577  * @brief Returns the bucket index of a given element.
578  * @param __key A key instance.
579  * @return The key bucket index.
580  */
581  size_type
582  bucket(const key_type& __key) const
583  { return _M_h.bucket(__key); }
584 
586 
592  local_iterator
593  begin(size_type __n)
594  { return _M_h.begin(__n); }
595 
596  const_local_iterator
597  begin(size_type __n) const
598  { return _M_h.begin(__n); }
599 
600  const_local_iterator
601  cbegin(size_type __n) const
602  { return _M_h.cbegin(__n); }
604 
606 
612  local_iterator
613  end(size_type __n)
614  { return _M_h.end(__n); }
615 
616  const_local_iterator
617  end(size_type __n) const
618  { return _M_h.end(__n); }
619 
620  const_local_iterator
621  cend(size_type __n) const
622  { return _M_h.cend(__n); }
624 
625  // hash policy.
626 
628  float
629  load_factor() const noexcept
630  { return _M_h.load_factor(); }
631 
634  float
635  max_load_factor() const noexcept
636  { return _M_h.max_load_factor(); }
637 
642  void
643  max_load_factor(float __z)
644  { _M_h.max_load_factor(__z); }
645 
653  void
654  rehash(size_type __n)
655  { _M_h.rehash(__n); }
656 
664  void
665  reserve(size_type __n)
666  { _M_h.reserve(__n); }
667 
668  template<typename _Value1, typename _Hash1, typename _Pred1,
669  typename _Alloc1>
670  friend bool
671  operator==(const unordered_set<_Value1, _Hash1, _Pred1, _Alloc1>&,
672  const unordered_set<_Value1, _Hash1, _Pred1, _Alloc1>&);
673  };
674 
694  template<class _Value,
695  class _Hash = hash<_Value>,
696  class _Pred = std::equal_to<_Value>,
697  class _Alloc = std::allocator<_Value> >
698  class unordered_multiset : __check_copy_constructible<_Alloc>
699  {
700  typedef __umset_hashtable<_Value, _Hash, _Pred, _Alloc> _Hashtable;
701  _Hashtable _M_h;
702 
703  public:
704  // typedefs:
706  typedef typename _Hashtable::key_type key_type;
708  typedef typename _Hashtable::value_type value_type;
709  typedef typename _Hashtable::hasher hasher;
710  typedef typename _Hashtable::key_equal key_equal;
711  typedef typename _Hashtable::allocator_type allocator_type;
713 
715  typedef typename allocator_type::pointer pointer;
717  typedef typename allocator_type::const_pointer const_pointer;
718  typedef typename allocator_type::reference reference;
719  typedef typename allocator_type::const_reference const_reference;
720  typedef typename _Hashtable::iterator iterator;
721  typedef typename _Hashtable::const_iterator const_iterator;
722  typedef typename _Hashtable::local_iterator local_iterator;
723  typedef typename _Hashtable::const_local_iterator const_local_iterator;
724  typedef typename _Hashtable::size_type size_type;
725  typedef typename _Hashtable::difference_type difference_type;
727 
728  // construct/destroy/copy
736  explicit
737  unordered_multiset(size_type __n = 10,
738  const hasher& __hf = hasher(),
739  const key_equal& __eql = key_equal(),
740  const allocator_type& __a = allocator_type())
741  : _M_h(__n, __hf, __eql, __a)
742  { }
743 
757  template<typename _InputIterator>
758  unordered_multiset(_InputIterator __f, _InputIterator __l,
759  size_type __n = 0,
760  const hasher& __hf = hasher(),
761  const key_equal& __eql = key_equal(),
762  const allocator_type& __a = allocator_type())
763  : _M_h(__f, __l, __n, __hf, __eql, __a)
764  { }
765 
767  unordered_multiset(const unordered_multiset&) = default;
768 
770  unordered_multiset(unordered_multiset&&) = default;
771 
783  unordered_multiset(initializer_list<value_type> __l,
784  size_type __n = 0,
785  const hasher& __hf = hasher(),
786  const key_equal& __eql = key_equal(),
787  const allocator_type& __a = allocator_type())
788  : _M_h(__l, __n, __hf, __eql, __a)
789  { }
790 
792  unordered_multiset&
793  operator=(const unordered_multiset&) = default;
794 
796  unordered_multiset&
797  operator=(unordered_multiset&& __x) = default;
798 
810  unordered_multiset&
811  operator=(initializer_list<value_type> __l)
812  {
813  _M_h = __l;
814  return *this;
815  }
816 
819  allocator_type
820  get_allocator() const noexcept
821  { return _M_h.get_allocator(); }
822 
823  // size and capacity:
824 
826  bool
827  empty() const noexcept
828  { return _M_h.empty(); }
829 
831  size_type
832  size() const noexcept
833  { return _M_h.size(); }
834 
836  size_type
837  max_size() const noexcept
838  { return _M_h.max_size(); }
839 
840  // iterators.
841 
843 
847  iterator
848  begin() noexcept
849  { return _M_h.begin(); }
850 
851  const_iterator
852  begin() const noexcept
853  { return _M_h.begin(); }
855 
857 
861  iterator
862  end() noexcept
863  { return _M_h.end(); }
864 
865  const_iterator
866  end() const noexcept
867  { return _M_h.end(); }
869 
874  const_iterator
875  cbegin() const noexcept
876  { return _M_h.begin(); }
877 
882  const_iterator
883  cend() const noexcept
884  { return _M_h.end(); }
885 
886  // modifiers.
887 
895  template<typename... _Args>
896  iterator
897  emplace(_Args&&... __args)
898  { return _M_h.emplace(std::forward<_Args>(__args)...); }
899 
917  template<typename... _Args>
918  iterator
919  emplace_hint(const_iterator __pos, _Args&&... __args)
920  { return _M_h.emplace_hint(__pos, std::forward<_Args>(__args)...); }
921 
923 
930  iterator
931  insert(const value_type& __x)
932  { return _M_h.insert(__x); }
933 
934  iterator
935  insert(value_type&& __x)
936  { return _M_h.insert(std::move(__x)); }
938 
940 
956  iterator
957  insert(const_iterator __hint, const value_type& __x)
958  { return _M_h.insert(__hint, __x); }
959 
960  iterator
961  insert(const_iterator __hint, value_type&& __x)
962  { return _M_h.insert(__hint, std::move(__x)); }
964 
973  template<typename _InputIterator>
974  void
975  insert(_InputIterator __first, _InputIterator __last)
976  { _M_h.insert(__first, __last); }
977 
985  void
986  insert(initializer_list<value_type> __l)
987  { _M_h.insert(__l); }
988 
990 
1004  iterator
1005  erase(const_iterator __position)
1006  { return _M_h.erase(__position); }
1007 
1008  // LWG 2059.
1009  iterator
1010  erase(iterator __it)
1011  { return _M_h.erase(__it); }
1013 
1014 
1027  size_type
1028  erase(const key_type& __x)
1029  { return _M_h.erase(__x); }
1030 
1047  iterator
1048  erase(const_iterator __first, const_iterator __last)
1049  { return _M_h.erase(__first, __last); }
1050 
1058  void
1059  clear() noexcept
1060  { _M_h.clear(); }
1061 
1071  void
1072  swap(unordered_multiset& __x)
1073  { _M_h.swap(__x._M_h); }
1074 
1075  // observers.
1076 
1079  hasher
1080  hash_function() const
1081  { return _M_h.hash_function(); }
1082 
1085  key_equal
1086  key_eq() const
1087  { return _M_h.key_eq(); }
1088 
1089  // lookup.
1090 
1092 
1103  iterator
1104  find(const key_type& __x)
1105  { return _M_h.find(__x); }
1106 
1107  const_iterator
1108  find(const key_type& __x) const
1109  { return _M_h.find(__x); }
1111 
1117  size_type
1118  count(const key_type& __x) const
1119  { return _M_h.count(__x); }
1120 
1122 
1128  std::pair<iterator, iterator>
1129  equal_range(const key_type& __x)
1130  { return _M_h.equal_range(__x); }
1131 
1132  std::pair<const_iterator, const_iterator>
1133  equal_range(const key_type& __x) const
1134  { return _M_h.equal_range(__x); }
1136 
1137  // bucket interface.
1138 
1140  size_type
1141  bucket_count() const noexcept
1142  { return _M_h.bucket_count(); }
1143 
1145  size_type
1146  max_bucket_count() const noexcept
1147  { return _M_h.max_bucket_count(); }
1148 
1149  /*
1150  * @brief Returns the number of elements in a given bucket.
1151  * @param __n A bucket index.
1152  * @return The number of elements in the bucket.
1153  */
1154  size_type
1155  bucket_size(size_type __n) const
1156  { return _M_h.bucket_size(__n); }
1157 
1158  /*
1159  * @brief Returns the bucket index of a given element.
1160  * @param __key A key instance.
1161  * @return The key bucket index.
1162  */
1163  size_type
1164  bucket(const key_type& __key) const
1165  { return _M_h.bucket(__key); }
1166 
1168 
1174  local_iterator
1175  begin(size_type __n)
1176  { return _M_h.begin(__n); }
1177 
1178  const_local_iterator
1179  begin(size_type __n) const
1180  { return _M_h.begin(__n); }
1181 
1182  const_local_iterator
1183  cbegin(size_type __n) const
1184  { return _M_h.cbegin(__n); }
1186 
1188 
1194  local_iterator
1195  end(size_type __n)
1196  { return _M_h.end(__n); }
1197 
1198  const_local_iterator
1199  end(size_type __n) const
1200  { return _M_h.end(__n); }
1201 
1202  const_local_iterator
1203  cend(size_type __n) const
1204  { return _M_h.cend(__n); }
1206 
1207  // hash policy.
1208 
1210  float
1211  load_factor() const noexcept
1212  { return _M_h.load_factor(); }
1213 
1216  float
1217  max_load_factor() const noexcept
1218  { return _M_h.max_load_factor(); }
1219 
1224  void
1225  max_load_factor(float __z)
1226  { _M_h.max_load_factor(__z); }
1227 
1235  void
1236  rehash(size_type __n)
1237  { _M_h.rehash(__n); }
1238 
1246  void
1247  reserve(size_type __n)
1248  { _M_h.reserve(__n); }
1249 
1250  template<typename _Value1, typename _Hash1, typename _Pred1,
1251  typename _Alloc1>
1252  friend bool
1253  operator==(const unordered_multiset<_Value1, _Hash1, _Pred1, _Alloc1>&,
1254  const unordered_multiset<_Value1, _Hash1, _Pred1, _Alloc1>&);
1255  };
1256 
1257  template<class _Value, class _Hash, class _Pred, class _Alloc>
1258  inline void
1259  swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1260  unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1261  { __x.swap(__y); }
1262 
1263  template<class _Value, class _Hash, class _Pred, class _Alloc>
1264  inline void
1265  swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1266  unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1267  { __x.swap(__y); }
1268 
1269  template<class _Value, class _Hash, class _Pred, class _Alloc>
1270  inline bool
1271  operator==(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1272  const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1273  { return __x._M_h._M_equal(__y._M_h); }
1274 
1275  template<class _Value, class _Hash, class _Pred, class _Alloc>
1276  inline bool
1277  operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
1278  const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
1279  { return !(__x == __y); }
1280 
1281  template<class _Value, class _Hash, class _Pred, class _Alloc>
1282  inline bool
1283  operator==(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1284  const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1285  { return __x._M_h._M_equal(__y._M_h); }
1286 
1287  template<class _Value, class _Hash, class _Pred, class _Alloc>
1288  inline bool
1289  operator!=(const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
1290  const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
1291  { return !(__x == __y); }
1292 
1293 _GLIBCXX_END_NAMESPACE_CONTAINER
1294 } // namespace std
bool operator==(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
bool operator!=(const exception_ptr &, const exception_ptr &) _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
void swap(exception_ptr &__lhs, exception_ptr &__rhs)
Definition: exception_ptr.h:160