57 #ifndef _BACKWARD_HASH_SET
58 #define _BACKWARD_HASH_SET 1
60 #ifndef _GLIBCXX_PERMIT_BACKWARD_HASH
68 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
70 _GLIBCXX_BEGIN_NAMESPACE_VERSION
82 template<
class _Value,
class _HashFcn = hash<_Value>,
83 class _EqualKey = equal_to<_Value>,
84 class _Alloc = allocator<_Value> >
88 __glibcxx_class_requires(_Value, _SGIAssignableConcept)
89 __glibcxx_class_requires3(_HashFcn,
size_t, _Value, _UnaryFunctionConcept)
90 __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
93 typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
94 _EqualKey, _Alloc> _Ht;
98 typedef typename _Ht::key_type key_type;
99 typedef typename _Ht::value_type value_type;
100 typedef typename _Ht::hasher hasher;
101 typedef typename _Ht::key_equal key_equal;
103 typedef typename _Ht::size_type size_type;
104 typedef typename _Ht::difference_type difference_type;
105 typedef typename _Alloc::pointer pointer;
106 typedef typename _Alloc::const_pointer const_pointer;
107 typedef typename _Alloc::reference reference;
108 typedef typename _Alloc::const_reference const_reference;
110 typedef typename _Ht::const_iterator iterator;
111 typedef typename _Ht::const_iterator const_iterator;
113 typedef typename _Ht::allocator_type allocator_type;
117 {
return _M_ht.hash_funct(); }
121 {
return _M_ht.key_eq(); }
124 get_allocator()
const
125 {
return _M_ht.get_allocator(); }
128 : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
132 : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
134 hash_set(size_type __n,
const hasher& __hf)
135 : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
137 hash_set(size_type __n,
const hasher& __hf,
const key_equal& __eql,
138 const allocator_type& __a = allocator_type())
139 : _M_ht(__n, __hf, __eql, __a) {}
141 template<
class _InputIterator>
142 hash_set(_InputIterator __f, _InputIterator __l)
143 : _M_ht(100, hasher(), key_equal(), allocator_type())
144 { _M_ht.insert_unique(__f, __l); }
146 template<
class _InputIterator>
147 hash_set(_InputIterator __f, _InputIterator __l, size_type __n)
148 : _M_ht(__n, hasher(), key_equal(), allocator_type())
149 { _M_ht.insert_unique(__f, __l); }
151 template<
class _InputIterator>
152 hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
154 : _M_ht(__n, __hf, key_equal(), allocator_type())
155 { _M_ht.insert_unique(__f, __l); }
157 template<
class _InputIterator>
158 hash_set(_InputIterator __f, _InputIterator __l, size_type __n,
159 const hasher& __hf,
const key_equal& __eql,
160 const allocator_type& __a = allocator_type())
161 : _M_ht(__n, __hf, __eql, __a)
162 { _M_ht.insert_unique(__f, __l); }
166 {
return _M_ht.size(); }
170 {
return _M_ht.max_size(); }
174 {
return _M_ht.empty(); }
178 { _M_ht.swap(__hs._M_ht); }
180 template<
class _Val,
class _HF,
class _EqK,
class _Al>
187 {
return _M_ht.begin(); }
191 {
return _M_ht.end(); }
194 insert(
const value_type& __obj)
200 template<
class _InputIterator>
202 insert(_InputIterator __f, _InputIterator __l)
203 { _M_ht.insert_unique(__f, __l); }
206 insert_noresize(
const value_type& __obj)
209 = _M_ht.insert_unique_noresize(__obj);
214 find(
const key_type& __key)
const
215 {
return _M_ht.find(__key); }
218 count(
const key_type& __key)
const
219 {
return _M_ht.count(__key); }
222 equal_range(
const key_type& __key)
const
223 {
return _M_ht.equal_range(__key); }
226 erase(
const key_type& __key)
227 {
return _M_ht.erase(__key); }
231 { _M_ht.erase(__it); }
234 erase(iterator __f, iterator __l)
235 { _M_ht.erase(__f, __l); }
242 resize(size_type __hint)
243 { _M_ht.resize(__hint); }
247 {
return _M_ht.bucket_count(); }
250 max_bucket_count()
const
251 {
return _M_ht.max_bucket_count(); }
254 elems_in_bucket(size_type __n)
const
255 {
return _M_ht.elems_in_bucket(__n); }
258 template<
class _Value,
class _HashFcn,
class _EqualKey,
class _Alloc>
262 {
return __hs1._M_ht == __hs2._M_ht; }
264 template<
class _Value,
class _HashFcn,
class _EqualKey,
class _Alloc>
266 operator!=(
const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
267 const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2)
268 {
return !(__hs1 == __hs2); }
270 template<
class _Val,
class _HashFcn,
class _EqualKey,
class _Alloc>
272 swap(hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
273 hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
274 { __hs1.swap(__hs2); }
282 template<
class _Value,
283 class _HashFcn = hash<_Value>,
284 class _EqualKey = equal_to<_Value>,
285 class _Alloc = allocator<_Value> >
289 __glibcxx_class_requires(_Value, _SGIAssignableConcept)
290 __glibcxx_class_requires3(_HashFcn,
size_t, _Value, _UnaryFunctionConcept)
291 __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
294 typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
295 _EqualKey, _Alloc> _Ht;
299 typedef typename _Ht::key_type key_type;
300 typedef typename _Ht::value_type value_type;
301 typedef typename _Ht::hasher hasher;
302 typedef typename _Ht::key_equal key_equal;
304 typedef typename _Ht::size_type size_type;
305 typedef typename _Ht::difference_type difference_type;
306 typedef typename _Alloc::pointer pointer;
307 typedef typename _Alloc::const_pointer const_pointer;
308 typedef typename _Alloc::reference reference;
309 typedef typename _Alloc::const_reference const_reference;
311 typedef typename _Ht::const_iterator iterator;
312 typedef typename _Ht::const_iterator const_iterator;
314 typedef typename _Ht::allocator_type allocator_type;
318 {
return _M_ht.hash_funct(); }
322 {
return _M_ht.key_eq(); }
325 get_allocator()
const
326 {
return _M_ht.get_allocator(); }
329 : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
333 : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
336 : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
338 hash_multiset(size_type __n,
const hasher& __hf,
const key_equal& __eql,
339 const allocator_type& __a = allocator_type())
340 : _M_ht(__n, __hf, __eql, __a) {}
342 template<
class _InputIterator>
344 : _M_ht(100, hasher(), key_equal(), allocator_type())
345 { _M_ht.insert_equal(__f, __l); }
347 template<
class _InputIterator>
348 hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n)
349 : _M_ht(__n, hasher(), key_equal(), allocator_type())
350 { _M_ht.insert_equal(__f, __l); }
352 template<
class _InputIterator>
353 hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
355 : _M_ht(__n, __hf, key_equal(), allocator_type())
356 { _M_ht.insert_equal(__f, __l); }
358 template<
class _InputIterator>
359 hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n,
360 const hasher& __hf,
const key_equal& __eql,
361 const allocator_type& __a = allocator_type())
362 : _M_ht(__n, __hf, __eql, __a)
363 { _M_ht.insert_equal(__f, __l); }
367 {
return _M_ht.size(); }
371 {
return _M_ht.max_size(); }
375 {
return _M_ht.empty(); }
379 { _M_ht.swap(hs._M_ht); }
381 template<
class _Val,
class _HF,
class _EqK,
class _Al>
388 {
return _M_ht.begin(); }
392 {
return _M_ht.end(); }
395 insert(
const value_type& __obj)
396 {
return _M_ht.insert_equal(__obj); }
398 template<
class _InputIterator>
400 insert(_InputIterator __f, _InputIterator __l)
401 { _M_ht.insert_equal(__f,__l); }
404 insert_noresize(
const value_type& __obj)
405 {
return _M_ht.insert_equal_noresize(__obj); }
408 find(
const key_type& __key)
const
409 {
return _M_ht.find(__key); }
412 count(
const key_type& __key)
const
413 {
return _M_ht.count(__key); }
416 equal_range(
const key_type& __key)
const
417 {
return _M_ht.equal_range(__key); }
420 erase(
const key_type& __key)
421 {
return _M_ht.erase(__key); }
425 { _M_ht.erase(__it); }
428 erase(iterator __f, iterator __l)
429 { _M_ht.erase(__f, __l); }
436 resize(size_type __hint)
437 { _M_ht.resize(__hint); }
441 {
return _M_ht.bucket_count(); }
444 max_bucket_count()
const
445 {
return _M_ht.max_bucket_count(); }
448 elems_in_bucket(size_type __n)
const
449 {
return _M_ht.elems_in_bucket(__n); }
452 template<
class _Val,
class _HashFcn,
class _EqualKey,
class _Alloc>
456 {
return __hs1._M_ht == __hs2._M_ht; }
458 template<
class _Val,
class _HashFcn,
class _EqualKey,
class _Alloc>
460 operator!=(
const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
461 const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
462 {
return !(__hs1 == __hs2); }
464 template<
class _Val,
class _HashFcn,
class _EqualKey,
class _Alloc>
466 swap(hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
467 hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
468 { __hs1.swap(__hs2); }
470 _GLIBCXX_END_NAMESPACE_VERSION
473 namespace std _GLIBCXX_VISIBILITY(default)
475 _GLIBCXX_BEGIN_NAMESPACE_VERSION
479 template<
class _Value,
class _HashFcn,
class _EqualKey,
class _Alloc>
480 class insert_iterator<__gnu_cxx::hash_set<_Value, _HashFcn,
486 _Container* container;
502 insert_iterator<_Container>&
503 operator=(
const typename _Container::value_type& __value)
505 container->insert(__value);
509 insert_iterator<_Container>&
513 insert_iterator<_Container>&
517 insert_iterator<_Container>&
522 template<
class _Value,
class _HashFcn,
class _EqualKey,
class _Alloc>
523 class insert_iterator<__gnu_cxx::hash_multiset<_Value, _HashFcn,
529 _Container* container;
530 typename _Container::iterator iter;
546 insert_iterator<_Container>&
547 operator=(
const typename _Container::value_type& __value)
549 container->insert(__value);
553 insert_iterator<_Container>&
557 insert_iterator<_Container>&
561 insert_iterator<_Container>&
565 _GLIBCXX_END_NAMESPACE_VERSION
Struct holding two objects of arbitrary type.
_T1 first
second_type is the second bound type
insert_iterator & operator*()
Simply returns *this.
insert_iterator(_Container &__x, typename _Container::iterator __i)
insert_iterator & operator=(const typename _Container::value_type &__value)
One of the comparison functors.
void difference_type
Distance between iterators is represented as this type.
void pointer
This type represents a pointer-to-value_type.
_Container container_type
A nested typedef for the type of whatever container you used.
insert_iterator & operator++()
Simply returns *this. (This iterator does not move.)
void value_type
The type "pointed to" by the iterator.
output_iterator_tag iterator_category
One of the tag types.
void reference
This type represents a reference-to-value_type.
The standard allocator, as per [20.4].Further details: http://gcc.gnu.org/onlinedocs/libstdc++/manual...
_T2 second
first is a copy of the first object