56 #ifndef _BACKWARD_HASH_SET
57 #define _BACKWARD_HASH_SET 1
59 #ifndef _GLIBCXX_PERMIT_BACKWARD_HASH
67 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
69 _GLIBCXX_BEGIN_NAMESPACE_VERSION
81 template<
class _Value,
class _HashFcn = hash<_Value>,
82 class _EqualKey = equal_to<_Value>,
83 class _Alloc = allocator<_Value> >
87 __glibcxx_class_requires(_Value, _SGIAssignableConcept)
88 __glibcxx_class_requires3(_HashFcn,
size_t, _Value, _UnaryFunctionConcept)
89 __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
94 typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
95 _EqualKey, _Alloc> _Ht;
99 typedef typename _Ht::key_type key_type;
100 typedef typename _Ht::value_type value_type;
101 typedef typename _Ht::hasher hasher;
102 typedef typename _Ht::key_equal key_equal;
104 typedef typename _Ht::size_type size_type;
105 typedef typename _Ht::difference_type difference_type;
106 typedef typename _Alloc_traits::pointer pointer;
107 typedef typename _Alloc_traits::const_pointer const_pointer;
108 typedef typename _Alloc_traits::reference reference;
109 typedef typename _Alloc_traits::const_reference const_reference;
111 typedef typename _Ht::const_iterator iterator;
112 typedef typename _Ht::const_iterator const_iterator;
114 typedef typename _Ht::allocator_type allocator_type;
118 {
return _M_ht.hash_funct(); }
122 {
return _M_ht.key_eq(); }
125 get_allocator()
const
126 {
return _M_ht.get_allocator(); }
129 : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
133 : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
135 hash_set(size_type __n,
const hasher& __hf)
136 : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
138 hash_set(size_type __n,
const hasher& __hf,
const key_equal& __eql,
139 const allocator_type& __a = allocator_type())
140 : _M_ht(__n, __hf, __eql, __a) {}
142 template<
class _InputIterator>
143 hash_set(_InputIterator __f, _InputIterator __l)
144 : _M_ht(100, hasher(), key_equal(), allocator_type())
145 { _M_ht.insert_unique(__f, __l); }
147 template<
class _InputIterator>
148 hash_set(_InputIterator __f, _InputIterator __l, size_type __n)
149 : _M_ht(__n, hasher(), key_equal(), allocator_type())
150 { _M_ht.insert_unique(__f, __l); }
152 template<
class _InputIterator>
153 hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
155 : _M_ht(__n, __hf, key_equal(), allocator_type())
156 { _M_ht.insert_unique(__f, __l); }
158 template<
class _InputIterator>
159 hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
160 const hasher& __hf,
const key_equal& __eql,
161 const allocator_type& __a = allocator_type())
162 : _M_ht(__n, __hf, __eql, __a)
163 { _M_ht.insert_unique(__f, __l); }
167 {
return _M_ht.size(); }
171 {
return _M_ht.max_size(); }
173 _GLIBCXX_NODISCARD
bool
175 {
return _M_ht.empty(); }
179 { _M_ht.swap(__hs._M_ht); }
181 template<
class _Val,
class _HF,
class _EqK,
class _Al>
188 {
return _M_ht.begin(); }
192 {
return _M_ht.end(); }
195 insert(
const value_type& __obj)
201 template<
class _InputIterator>
203 insert(_InputIterator __f, _InputIterator __l)
204 { _M_ht.insert_unique(__f, __l); }
207 insert_noresize(
const value_type& __obj)
210 = _M_ht.insert_unique_noresize(__obj);
215 find(
const key_type& __key)
const
216 {
return _M_ht.find(__key); }
219 count(
const key_type& __key)
const
220 {
return _M_ht.count(__key); }
223 equal_range(
const key_type& __key)
const
224 {
return _M_ht.equal_range(__key); }
227 erase(
const key_type& __key)
228 {
return _M_ht.erase(__key); }
232 { _M_ht.erase(__it); }
235 erase(iterator __f, iterator __l)
236 { _M_ht.erase(__f, __l); }
243 resize(size_type __hint)
244 { _M_ht.resize(__hint); }
248 {
return _M_ht.bucket_count(); }
251 max_bucket_count()
const
252 {
return _M_ht.max_bucket_count(); }
255 elems_in_bucket(size_type __n)
const
256 {
return _M_ht.elems_in_bucket(__n); }
259 template<
class _Value,
class _HashFcn,
class _EqualKey,
class _Alloc>
263 {
return __hs1._M_ht == __hs2._M_ht; }
265 template<
class _Value,
class _HashFcn,
class _EqualKey,
class _Alloc>
267 operator!=(
const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
268 const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2)
269 {
return !(__hs1 == __hs2); }
271 template<
class _Val,
class _HashFcn,
class _EqualKey,
class _Alloc>
273 swap(hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
274 hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
275 { __hs1.swap(__hs2); }
283 template<
class _Value,
284 class _HashFcn = hash<_Value>,
285 class _EqualKey = equal_to<_Value>,
286 class _Alloc = allocator<_Value> >
290 __glibcxx_class_requires(_Value, _SGIAssignableConcept)
291 __glibcxx_class_requires3(_HashFcn,
size_t, _Value, _UnaryFunctionConcept)
292 __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
295 typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
296 _EqualKey, _Alloc> _Ht;
300 typedef typename _Ht::key_type key_type;
301 typedef typename _Ht::value_type value_type;
302 typedef typename _Ht::hasher hasher;
303 typedef typename _Ht::key_equal key_equal;
305 typedef typename _Ht::size_type size_type;
306 typedef typename _Ht::difference_type difference_type;
307 typedef typename _Alloc::pointer pointer;
308 typedef typename _Alloc::const_pointer const_pointer;
309 typedef typename _Alloc::reference reference;
310 typedef typename _Alloc::const_reference const_reference;
312 typedef typename _Ht::const_iterator iterator;
313 typedef typename _Ht::const_iterator const_iterator;
315 typedef typename _Ht::allocator_type allocator_type;
319 {
return _M_ht.hash_funct(); }
323 {
return _M_ht.key_eq(); }
326 get_allocator()
const
327 {
return _M_ht.get_allocator(); }
330 : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
334 : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
337 : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
339 hash_multiset(size_type __n,
const hasher& __hf,
const key_equal& __eql,
340 const allocator_type& __a = allocator_type())
341 : _M_ht(__n, __hf, __eql, __a) {}
343 template<
class _InputIterator>
345 : _M_ht(100, hasher(), key_equal(), allocator_type())
346 { _M_ht.insert_equal(__f, __l); }
348 template<
class _InputIterator>
349 hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n)
350 : _M_ht(__n, hasher(), key_equal(), allocator_type())
351 { _M_ht.insert_equal(__f, __l); }
353 template<
class _InputIterator>
354 hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
356 : _M_ht(__n, __hf, key_equal(), allocator_type())
357 { _M_ht.insert_equal(__f, __l); }
359 template<
class _InputIterator>
360 hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
361 const hasher& __hf,
const key_equal& __eql,
362 const allocator_type& __a = allocator_type())
363 : _M_ht(__n, __hf, __eql, __a)
364 { _M_ht.insert_equal(__f, __l); }
368 {
return _M_ht.size(); }
372 {
return _M_ht.max_size(); }
374 _GLIBCXX_NODISCARD
bool
376 {
return _M_ht.empty(); }
380 { _M_ht.swap(hs._M_ht); }
382 template<
class _Val,
class _HF,
class _EqK,
class _Al>
389 {
return _M_ht.begin(); }
393 {
return _M_ht.end(); }
396 insert(
const value_type& __obj)
397 {
return _M_ht.insert_equal(__obj); }
399 template<
class _InputIterator>
401 insert(_InputIterator __f, _InputIterator __l)
402 { _M_ht.insert_equal(__f,__l); }
405 insert_noresize(
const value_type& __obj)
406 {
return _M_ht.insert_equal_noresize(__obj); }
409 find(
const key_type& __key)
const
410 {
return _M_ht.find(__key); }
413 count(
const key_type& __key)
const
414 {
return _M_ht.count(__key); }
417 equal_range(
const key_type& __key)
const
418 {
return _M_ht.equal_range(__key); }
421 erase(
const key_type& __key)
422 {
return _M_ht.erase(__key); }
426 { _M_ht.erase(__it); }
429 erase(iterator __f, iterator __l)
430 { _M_ht.erase(__f, __l); }
437 resize(size_type __hint)
438 { _M_ht.resize(__hint); }
442 {
return _M_ht.bucket_count(); }
445 max_bucket_count()
const
446 {
return _M_ht.max_bucket_count(); }
449 elems_in_bucket(size_type __n)
const
450 {
return _M_ht.elems_in_bucket(__n); }
453 template<
class _Val,
class _HashFcn,
class _EqualKey,
class _Alloc>
457 {
return __hs1._M_ht == __hs2._M_ht; }
459 template<
class _Val,
class _HashFcn,
class _EqualKey,
class _Alloc>
461 operator!=(
const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
462 const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
463 {
return !(__hs1 == __hs2); }
465 template<
class _Val,
class _HashFcn,
class _EqualKey,
class _Alloc>
467 swap(hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
468 hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
469 { __hs1.swap(__hs2); }
471 _GLIBCXX_END_NAMESPACE_VERSION
474 namespace std _GLIBCXX_VISIBILITY(default)
476 _GLIBCXX_BEGIN_NAMESPACE_VERSION
480 template<
class _Value,
class _HashFcn,
class _EqualKey,
class _Alloc>
481 class insert_iterator<__gnu_cxx::hash_set<_Value, _HashFcn,
487 _Container* container;
503 insert_iterator<_Container>&
504 operator=(
const typename _Container::value_type& __value)
506 container->insert(__value);
510 insert_iterator<_Container>&
514 insert_iterator<_Container>&
518 insert_iterator<_Container>&
523 template<
class _Value,
class _HashFcn,
class _EqualKey,
class _Alloc>
524 class insert_iterator<__gnu_cxx::hash_multiset<_Value, _HashFcn,
530 _Container* container;
531 typename _Container::iterator iter;
547 insert_iterator<_Container>&
548 operator=(
const typename _Container::value_type& __value)
550 container->insert(__value);
554 insert_iterator<_Container>&
558 insert_iterator<_Container>&
562 insert_iterator<_Container>&
566 _GLIBCXX_END_NAMESPACE_VERSION
constexpr insert_iterator(_Container &__x, _Iter __i)
_Container container_type
A nested typedef for the type of whatever container you used.
One of the comparison functors.
constexpr insert_iterator & operator*()
Simply returns *this.
void reference
This type represents a reference-to-value_type.
Uniform interface to C++98 and C++11 allocators.
_T1 first
The first member.
void pointer
This type represents a pointer-to-value_type.
The standard allocator, as per [20.4].
_T2 second
The second member.
void difference_type
Distance between iterators is represented as this type.
constexpr insert_iterator & operator=(const typename _Container::value_type &__value)
output_iterator_tag iterator_category
One of the tag types.
Struct holding two objects of arbitrary type.
constexpr insert_iterator & operator++()
Simply returns *this. (This iterator does not move.)
void value_type
The type "pointed to" by the iterator.