57 #ifndef _BACKWARD_HASH_SET
58 #define _BACKWARD_HASH_SET 1
60 #include "backward_warning.h"
65 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
77 template<class _Value, class _HashFcn = hash<_Value>,
78 class _EqualKey = equal_to<_Value>,
79 class _Alloc = allocator<_Value> >
83 __glibcxx_class_requires(_Value, _SGIAssignableConcept)
84 __glibcxx_class_requires3(_HashFcn,
size_t, _Value, _UnaryFunctionConcept)
85 __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
88 typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
89 _EqualKey, _Alloc> _Ht;
93 typedef typename _Ht::key_type key_type;
94 typedef typename _Ht::value_type value_type;
95 typedef typename _Ht::hasher hasher;
96 typedef typename _Ht::key_equal key_equal;
98 typedef typename _Ht::size_type size_type;
99 typedef typename _Ht::difference_type difference_type;
100 typedef typename _Alloc::pointer pointer;
101 typedef typename _Alloc::const_pointer const_pointer;
102 typedef typename _Alloc::reference reference;
103 typedef typename _Alloc::const_reference const_reference;
105 typedef typename _Ht::const_iterator iterator;
106 typedef typename _Ht::const_iterator const_iterator;
108 typedef typename _Ht::allocator_type allocator_type;
112 {
return _M_ht.hash_funct(); }
116 {
return _M_ht.key_eq(); }
119 get_allocator()
const
120 {
return _M_ht.get_allocator(); }
123 : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
126 hash_set(size_type __n)
127 : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
129 hash_set(size_type __n,
const hasher& __hf)
130 : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
132 hash_set(size_type __n,
const hasher& __hf,
const key_equal& __eql,
133 const allocator_type& __a = allocator_type())
134 : _M_ht(__n, __hf, __eql, __a) {}
136 template<
class _InputIterator>
137 hash_set(_InputIterator __f, _InputIterator __l)
138 : _M_ht(100, hasher(), key_equal(), allocator_type())
139 { _M_ht.insert_unique(__f, __l); }
141 template<
class _InputIterator>
142 hash_set(_InputIterator __f, _InputIterator __l, size_type __n)
143 : _M_ht(__n, 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,
149 : _M_ht(__n, __hf, 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,
154 const hasher& __hf,
const key_equal& __eql,
155 const allocator_type& __a = allocator_type())
156 : _M_ht(__n, __hf, __eql, __a)
157 { _M_ht.insert_unique(__f, __l); }
161 {
return _M_ht.size(); }
165 {
return _M_ht.max_size(); }
169 {
return _M_ht.empty(); }
173 { _M_ht.swap(__hs._M_ht); }
175 template<
class _Val,
class _HF,
class _EqK,
class _Al>
182 {
return _M_ht.begin(); }
186 {
return _M_ht.end(); }
189 insert(
const value_type& __obj)
195 template<
class _InputIterator>
197 insert(_InputIterator __f, _InputIterator __l)
198 { _M_ht.insert_unique(__f, __l); }
201 insert_noresize(
const value_type& __obj)
204 = _M_ht.insert_unique_noresize(__obj);
209 find(
const key_type& __key)
const
210 {
return _M_ht.find(__key); }
213 count(
const key_type& __key)
const
214 {
return _M_ht.count(__key); }
217 equal_range(
const key_type& __key)
const
218 {
return _M_ht.equal_range(__key); }
221 erase(
const key_type& __key)
222 {
return _M_ht.erase(__key); }
226 { _M_ht.erase(__it); }
229 erase(iterator __f, iterator __l)
230 { _M_ht.erase(__f, __l); }
237 resize(size_type __hint)
238 { _M_ht.resize(__hint); }
242 {
return _M_ht.bucket_count(); }
245 max_bucket_count()
const
246 {
return _M_ht.max_bucket_count(); }
249 elems_in_bucket(size_type __n)
const
250 {
return _M_ht.elems_in_bucket(__n); }
253 template<
class _Value,
class _HashFcn,
class _EqualKey,
class _Alloc>
257 {
return __hs1._M_ht == __hs2._M_ht; }
259 template<
class _Value,
class _HashFcn,
class _EqualKey,
class _Alloc>
261 operator!=(
const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs1,
262 const hash_set<_Value, _HashFcn, _EqualKey, _Alloc>& __hs2)
263 {
return !(__hs1 == __hs2); }
265 template<
class _Val,
class _HashFcn,
class _EqualKey,
class _Alloc>
267 swap(hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
268 hash_set<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
269 { __hs1.swap(__hs2); }
277 template<
class _Value,
278 class _HashFcn = hash<_Value>,
279 class _EqualKey = equal_to<_Value>,
280 class _Alloc = allocator<_Value> >
284 __glibcxx_class_requires(_Value, _SGIAssignableConcept)
285 __glibcxx_class_requires3(_HashFcn,
size_t, _Value, _UnaryFunctionConcept)
286 __glibcxx_class_requires3(_EqualKey, _Value, _Value, _BinaryPredicateConcept)
289 typedef hashtable<_Value, _Value, _HashFcn, _Identity<_Value>,
290 _EqualKey, _Alloc> _Ht;
294 typedef typename _Ht::key_type key_type;
295 typedef typename _Ht::value_type value_type;
296 typedef typename _Ht::hasher hasher;
297 typedef typename _Ht::key_equal key_equal;
299 typedef typename _Ht::size_type size_type;
300 typedef typename _Ht::difference_type difference_type;
301 typedef typename _Alloc::pointer pointer;
302 typedef typename _Alloc::const_pointer const_pointer;
303 typedef typename _Alloc::reference reference;
304 typedef typename _Alloc::const_reference const_reference;
306 typedef typename _Ht::const_iterator iterator;
307 typedef typename _Ht::const_iterator const_iterator;
309 typedef typename _Ht::allocator_type allocator_type;
313 {
return _M_ht.hash_funct(); }
317 {
return _M_ht.key_eq(); }
320 get_allocator()
const
321 {
return _M_ht.get_allocator(); }
324 : _M_ht(100, hasher(), key_equal(), allocator_type()) {}
328 : _M_ht(__n, hasher(), key_equal(), allocator_type()) {}
331 : _M_ht(__n, __hf, key_equal(), allocator_type()) {}
333 hash_multiset(size_type __n,
const hasher& __hf,
const key_equal& __eql,
334 const allocator_type& __a = allocator_type())
335 : _M_ht(__n, __hf, __eql, __a) {}
337 template<
class _InputIterator>
339 : _M_ht(100, hasher(), key_equal(), allocator_type())
340 { _M_ht.insert_equal(__f, __l); }
342 template<
class _InputIterator>
343 hash_multiset(_InputIterator __f, _InputIterator __l, size_type __n)
344 : _M_ht(__n, 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,
350 : _M_ht(__n, __hf, 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,
355 const hasher& __hf,
const key_equal& __eql,
356 const allocator_type& __a = allocator_type())
357 : _M_ht(__n, __hf, __eql, __a)
358 { _M_ht.insert_equal(__f, __l); }
362 {
return _M_ht.size(); }
366 {
return _M_ht.max_size(); }
370 {
return _M_ht.empty(); }
374 { _M_ht.swap(hs._M_ht); }
376 template<
class _Val,
class _HF,
class _EqK,
class _Al>
383 {
return _M_ht.begin(); }
387 {
return _M_ht.end(); }
390 insert(
const value_type& __obj)
391 {
return _M_ht.insert_equal(__obj); }
393 template<
class _InputIterator>
395 insert(_InputIterator __f, _InputIterator __l)
396 { _M_ht.insert_equal(__f,__l); }
399 insert_noresize(
const value_type& __obj)
400 {
return _M_ht.insert_equal_noresize(__obj); }
403 find(
const key_type& __key)
const
404 {
return _M_ht.find(__key); }
407 count(
const key_type& __key)
const
408 {
return _M_ht.count(__key); }
411 equal_range(
const key_type& __key)
const
412 {
return _M_ht.equal_range(__key); }
415 erase(
const key_type& __key)
416 {
return _M_ht.erase(__key); }
420 { _M_ht.erase(__it); }
423 erase(iterator __f, iterator __l)
424 { _M_ht.erase(__f, __l); }
431 resize(size_type __hint)
432 { _M_ht.resize(__hint); }
436 {
return _M_ht.bucket_count(); }
439 max_bucket_count()
const
440 {
return _M_ht.max_bucket_count(); }
443 elems_in_bucket(size_type __n)
const
444 {
return _M_ht.elems_in_bucket(__n); }
447 template<
class _Val,
class _HashFcn,
class _EqualKey,
class _Alloc>
451 {
return __hs1._M_ht == __hs2._M_ht; }
453 template<
class _Val,
class _HashFcn,
class _EqualKey,
class _Alloc>
455 operator!=(
const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
456 const hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
457 {
return !(__hs1 == __hs2); }
459 template<
class _Val,
class _HashFcn,
class _EqualKey,
class _Alloc>
461 swap(hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs1,
462 hash_multiset<_Val, _HashFcn, _EqualKey, _Alloc>& __hs2)
463 { __hs1.swap(__hs2); }
465 _GLIBCXX_END_NAMESPACE
467 _GLIBCXX_BEGIN_NAMESPACE(std)
471 template<class _Value, class _HashFcn, class _EqualKey, class _Alloc>
472 class insert_iterator<__gnu_cxx::hash_set<_Value, _HashFcn,
478 _Container* container;
481 typedef _Container container_type;
482 typedef output_iterator_tag iterator_category;
483 typedef void value_type;
484 typedef void difference_type;
485 typedef void pointer;
486 typedef void reference;
488 insert_iterator(_Container& __x)
491 insert_iterator(_Container& __x,
typename _Container::iterator)
494 insert_iterator<_Container>&
495 operator=(
const typename _Container::value_type& __value)
497 container->insert(__value);
501 insert_iterator<_Container>&
505 insert_iterator<_Container>&
509 insert_iterator<_Container>&
514 template<
class _Value,
class _HashFcn,
class _EqualKey,
class _Alloc>
515 class insert_iterator<__gnu_cxx::hash_multiset<_Value, _HashFcn,
521 _Container* container;
522 typename _Container::iterator iter;
525 typedef _Container container_type;
526 typedef output_iterator_tag iterator_category;
527 typedef void value_type;
528 typedef void difference_type;
529 typedef void pointer;
530 typedef void reference;
532 insert_iterator(_Container& __x)
535 insert_iterator(_Container& __x,
typename _Container::iterator)
538 insert_iterator<_Container>&
539 operator=(
const typename _Container::value_type& __value)
541 container->insert(__value);
545 insert_iterator<_Container>&
549 insert_iterator<_Container>&
553 insert_iterator<_Container>&
554 operator++(
int) {
return *
this; }
557 _GLIBCXX_END_NAMESPACE