28 #ifndef _GLIBCXX_PROFILE_UNORDERED_SET
29 #define _GLIBCXX_PROFILE_UNORDERED_SET 1
31 #ifndef __GXX_EXPERIMENTAL_CXX0X__
38 #define _GLIBCXX_BASE unordered_set<_Key, _Hash, _Pred, _Alloc>
39 #define _GLIBCXX_STD_BASE _GLIBCXX_STD_C::_GLIBCXX_BASE
41 namespace std _GLIBCXX_VISIBILITY(default)
46 template<
typename _Key,
51 :
public _GLIBCXX_STD_BASE
53 typedef typename _GLIBCXX_STD_BASE
_Base;
56 typedef typename _Base::size_type size_type;
57 typedef typename _Base::hasher hasher;
58 typedef typename _Base::key_equal key_equal;
59 typedef typename _Base::allocator_type allocator_type;
60 typedef typename _Base::key_type key_type;
61 typedef typename _Base::value_type value_type;
62 typedef typename _Base::difference_type difference_type;
63 typedef typename _Base::reference reference;
64 typedef typename _Base::const_reference const_reference;
66 typedef typename _Base::iterator iterator;
67 typedef typename _Base::const_iterator const_iterator;
71 const hasher& __hf = hasher(),
72 const key_equal& __eql = key_equal(),
73 const allocator_type& __a = allocator_type())
74 :
_Base(__n, __hf, __eql, __a)
76 __profcxx_hashtable_construct(
this, _Base::bucket_count());
77 __profcxx_hashtable_construct2(
this);
80 template<
typename _InputIterator>
83 const hasher& __hf = hasher(),
84 const key_equal& __eql = key_equal(),
85 const allocator_type& __a = allocator_type())
86 :
_Base(__f, __l, __n, __hf, __eql, __a)
88 __profcxx_hashtable_construct(
this, _Base::bucket_count());
89 __profcxx_hashtable_construct2(
this);
95 __profcxx_hashtable_construct(
this, _Base::bucket_count());
96 __profcxx_hashtable_construct2(
this);
100 :
_Base(std::move(__x))
102 __profcxx_hashtable_construct(
this, _Base::bucket_count());
103 __profcxx_hashtable_construct2(
this);
108 const hasher& __hf = hasher(),
109 const key_equal& __eql = key_equal(),
110 const allocator_type& __a = allocator_type())
111 :
_Base(__l, __n, __hf, __eql, __a) { }
116 *
static_cast<_Base*
>(
this) = __x;
140 __profcxx_hashtable_destruct(
this, _Base::bucket_count(),
142 _M_profile_destruct();
154 __profcxx_hashtable_destruct(
this, _Base::bucket_count(),
156 _M_profile_destruct();
163 size_type __old_size = _Base::bucket_count();
165 _M_profile_resize(__old_size, _Base::bucket_count());
169 insert(
const value_type& __obj)
171 size_type __old_size = _Base::bucket_count();
173 _M_profile_resize(__old_size, _Base::bucket_count());
178 insert(const_iterator __iter,
const value_type& __v)
180 size_type __old_size = _Base::bucket_count();
181 iterator __res = _Base::insert(__iter, __v);
182 _M_profile_resize(__old_size, _Base::bucket_count());
187 insert(value_type&& __obj)
189 size_type __old_size = _Base::bucket_count();
191 _M_profile_resize(__old_size, _Base::bucket_count());
196 insert(const_iterator __iter, value_type&& __v)
198 size_type __old_size = _Base::bucket_count();
199 iterator __res = _Base::insert(__iter, std::move(__v));
200 _M_profile_resize(__old_size, _Base::bucket_count());
204 template<
typename _InputIter>
206 insert(_InputIter __first, _InputIter __last)
208 size_type __old_size = _Base::bucket_count();
209 _Base::insert(__first, __last);
210 _M_profile_resize(__old_size, _Base::bucket_count());
214 insert(
const value_type* __first,
const value_type* __last)
216 size_type __old_size = _Base::bucket_count();
217 _Base::insert(__first, __last);
218 _M_profile_resize(__old_size, _Base::bucket_count());
221 void rehash(size_type __n)
223 size_type __old_size = _Base::bucket_count();
225 _M_profile_resize(__old_size, _Base::bucket_count());
230 _M_base() {
return *
this; }
233 _M_base()
const {
return *
this; }
236 _M_profile_resize(size_type __old_size, size_type __new_size)
238 if (__old_size != __new_size)
239 __profcxx_hashtable_resize(
this, __old_size, __new_size);
243 _M_profile_destruct()
245 size_type __hops = 0, __lc = 0, __chain = 0;
246 for (iterator __it = _M_base().
begin(); __it != _M_base().end();
249 while (__it._M_cur_node->_M_next)
258 __lc = __lc > __chain ? __lc : __chain;
259 __hops += __chain * (__chain - 1) / 2;
263 __profcxx_hashtable_destruct2(
this, __lc,
_Base::size(), __hops);
268 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
274 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
278 {
return __x._M_equal(__y); }
280 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
282 operator!=(
const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
283 const unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
284 {
return !(__x == __y); }
287 #undef _GLIBCXX_STD_BASE
288 #define _GLIBCXX_STD_BASE _GLIBCXX_STD_C::_GLIBCXX_BASE
289 #define _GLIBCXX_BASE unordered_multiset<_Value, _Hash, _Pred, _Alloc>
292 template<
typename _Value,
297 :
public _GLIBCXX_STD_BASE
299 typedef typename _GLIBCXX_STD_BASE
_Base;
302 typedef typename _Base::size_type size_type;
303 typedef typename _Base::hasher hasher;
304 typedef typename _Base::key_equal key_equal;
305 typedef typename _Base::allocator_type allocator_type;
306 typedef typename _Base::key_type key_type;
307 typedef typename _Base::value_type value_type;
308 typedef typename _Base::difference_type difference_type;
309 typedef typename _Base::reference reference;
310 typedef typename _Base::const_reference const_reference;
312 typedef typename _Base::iterator iterator;
313 typedef typename _Base::const_iterator const_iterator;
317 const hasher& __hf = hasher(),
318 const key_equal& __eql = key_equal(),
319 const allocator_type& __a = allocator_type())
320 :
_Base(__n, __hf, __eql, __a)
322 __profcxx_hashtable_construct(
this, _Base::bucket_count());
325 template<
typename _InputIterator>
328 const hasher& __hf = hasher(),
329 const key_equal& __eql = key_equal(),
330 const allocator_type& __a = allocator_type())
331 :
_Base(__f, __l, __n, __hf, __eql, __a)
333 __profcxx_hashtable_construct(
this, _Base::bucket_count());
339 __profcxx_hashtable_construct(
this, _Base::bucket_count());
343 :
_Base(std::move(__x))
345 __profcxx_hashtable_construct(
this, _Base::bucket_count());
350 const hasher& __hf = hasher(),
351 const key_equal& __eql = key_equal(),
352 const allocator_type& __a = allocator_type())
353 :
_Base(__l, __n, __hf, __eql, __a) { }
358 *
static_cast<_Base*
>(
this) = __x;
382 __profcxx_hashtable_destruct(
this, _Base::bucket_count(),
384 _M_profile_destruct();
396 __profcxx_hashtable_destruct(
this, _Base::bucket_count(),
398 _M_profile_destruct();
405 size_type __old_size = _Base::bucket_count();
407 _M_profile_resize(__old_size, _Base::bucket_count());
411 insert(
const value_type& __obj)
413 size_type __old_size = _Base::bucket_count();
414 iterator __res = _Base::insert(__obj);
415 _M_profile_resize(__old_size, _Base::bucket_count());
420 insert(const_iterator __iter,
const value_type& __v)
422 size_type __old_size = _Base::bucket_count();
423 iterator __res = _Base::insert(__iter, __v);
424 _M_profile_resize(__old_size, _Base::bucket_count());
429 insert(value_type&& __obj)
431 size_type __old_size = _Base::bucket_count();
432 iterator __res = _Base::insert(std::move(__obj));
433 _M_profile_resize(__old_size, _Base::bucket_count());
438 insert(const_iterator __iter, value_type&& __v)
440 size_type __old_size = _Base::bucket_count();
441 iterator __res = _Base::insert(__iter, std::move(__v));
442 _M_profile_resize(__old_size, _Base::bucket_count());
446 template<
typename _InputIter>
448 insert(_InputIter __first, _InputIter __last)
450 size_type __old_size = _Base::bucket_count();
451 _Base::insert(__first, __last);
452 _M_profile_resize(__old_size, _Base::bucket_count());
456 insert(
const value_type* __first,
const value_type* __last)
458 size_type __old_size = _Base::bucket_count();
459 _Base::insert(__first, __last);
460 _M_profile_resize(__old_size, _Base::bucket_count());
463 void rehash(size_type __n)
465 size_type __old_size = _Base::bucket_count();
467 _M_profile_resize(__old_size, _Base::bucket_count());
472 _M_base() {
return *
this; }
475 _M_base()
const {
return *
this; }
478 _M_profile_resize(size_type __old_size, size_type __new_size)
480 if (__old_size != __new_size)
481 __profcxx_hashtable_resize(
this, __old_size, __new_size);
485 _M_profile_destruct()
487 size_type __hops = 0, __lc = 0, __chain = 0;
488 for (iterator __it = _M_base().
begin(); __it != _M_base().end();
491 while (__it._M_cur_node->_M_next)
500 __lc = __lc > __chain ? __lc : __chain;
501 __hops += __chain * (__chain - 1) / 2;
505 __profcxx_hashtable_destruct2(
this, __lc,
_Base::size(), __hops);
510 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
516 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
520 {
return __x._M_equal(__y); }
522 template<
typename _Value,
typename _Hash,
typename _Pred,
typename _Alloc>
524 operator!=(
const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
525 const unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
526 {
return !(__x == __y); }
532 #undef _GLIBCXX_STD_BASE
534 #endif // __GXX_EXPERIMENTAL_CXX0X__