29 #ifndef _GLIBCXX_PROFILE_SET_H 30 #define _GLIBCXX_PROFILE_SET_H 1 35 namespace std _GLIBCXX_VISIBILITY(default)
40 template<
typename _Key,
typename _Compare = std::less<_Key>,
41 typename _Allocator = std::allocator<_Key> >
43 :
public _GLIBCXX_STD_C::set<_Key,_Compare,_Allocator>,
44 public _Ordered_profile<set<_Key, _Compare, _Allocator> >
46 typedef _GLIBCXX_STD_C::set<_Key, _Compare, _Allocator>
_Base;
48 typedef typename _Base::iterator _Base_iterator;
49 typedef typename _Base::const_iterator _Base_const_iterator;
53 typedef _Key key_type;
54 typedef _Key value_type;
55 typedef _Compare key_compare;
56 typedef _Compare value_compare;
57 typedef typename _Base::reference reference;
58 typedef typename _Base::const_reference const_reference;
60 typedef __iterator_tracker<_Base_iterator, set> iterator;
61 typedef __iterator_tracker<_Base_const_iterator,
66 typedef typename _Base::size_type size_type;
67 typedef typename _Base::difference_type difference_type;
70 #if __cplusplus < 201103L 78 set(
const set&) =
default;
83 explicit set(
const _Compare& __comp,
84 const _Allocator& __a = _Allocator())
85 : _Base(__comp, __a) { }
87 #if __cplusplus >= 201103L 88 template<
typename _InputIterator,
89 typename = std::_RequireInputIter<_InputIterator>>
91 template<
typename _InputIterator>
93 set(_InputIterator __first, _InputIterator __last,
94 const _Compare& __comp = _Compare(),
95 const _Allocator& __a = _Allocator())
96 : _Base(__first, __last, __comp, __a) { }
98 #if __cplusplus >= 201103L 100 const _Compare& __comp = _Compare(),
101 const _Allocator& __a = _Allocator())
102 : _Base(__l, __comp, __a) { }
105 set(
const _Allocator& __a)
108 set(
const set& __x,
const _Allocator& __a)
109 : _Base(__x, __a) { }
111 set(
set&& __x,
const _Allocator& __a)
112 noexcept( noexcept(_Base(std::move(__x), __a)) )
113 : _Base(std::move(__x), __a) { }
116 : _Base(__l, __a) { }
118 template<
typename _InputIterator>
119 set(_InputIterator __first, _InputIterator __last,
120 const _Allocator& __a)
121 : _Base(__first, __last, __a) { }
124 set(
const _Base& __x)
127 #if __cplusplus < 201103L 129 operator=(
const set& __x)
131 this->_M_profile_destruct();
133 this->_M_profile_construct();
138 operator=(
const set&) =
default;
141 operator=(
set&&) =
default;
146 this->_M_profile_destruct();
148 this->_M_profile_construct();
155 begin() _GLIBCXX_NOEXCEPT
156 {
return iterator(_Base::begin(),
this); }
159 begin()
const _GLIBCXX_NOEXCEPT
160 {
return const_iterator(_Base::begin(),
this); }
163 end() _GLIBCXX_NOEXCEPT
164 {
return iterator(_Base::end(),
this); }
167 end()
const _GLIBCXX_NOEXCEPT
168 {
return const_iterator(_Base::end(),
this); }
170 #if __cplusplus >= 201103L 172 cbegin()
const noexcept
173 {
return const_iterator(_Base::cbegin(),
this); }
176 cend()
const noexcept
177 {
return const_iterator(_Base::cend(),
this); }
181 rbegin() _GLIBCXX_NOEXCEPT
183 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
184 return reverse_iterator(end());
187 const_reverse_iterator
188 rbegin()
const _GLIBCXX_NOEXCEPT
190 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
191 return const_reverse_iterator(end());
195 rend() _GLIBCXX_NOEXCEPT
197 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
198 return reverse_iterator(begin());
201 const_reverse_iterator
202 rend()
const _GLIBCXX_NOEXCEPT
204 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
205 return const_reverse_iterator(begin());
208 #if __cplusplus >= 201103L 209 const_reverse_iterator
210 crbegin()
const noexcept
212 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
213 return const_reverse_iterator(cend());
216 const_reverse_iterator
217 crend()
const noexcept
219 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
220 return const_reverse_iterator(cbegin());
226 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
233 #if __cplusplus >= 201103L 234 template<
typename... _Args>
236 emplace(_Args&&... __args)
238 __profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
239 auto __base_ret = _Base::emplace(std::forward<_Args>(__args)...);
244 template<
typename... _Args>
246 emplace_hint(const_iterator __pos, _Args&&... __args)
248 auto size_before = this->size();
250 = _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...);
251 __profcxx_map2umap_insert(this->_M_map2umap_info,
252 size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
253 return iterator(__res,
this);
258 insert(
const value_type& __x)
260 __profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
266 #if __cplusplus >= 201103L 268 insert(value_type&& __x)
270 __profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
272 = _Base::insert(std::move(__x));
279 insert(const_iterator __pos,
const value_type& __x)
281 size_type size_before = this->size();
282 _Base_iterator __res = _Base::insert(__pos.base(), __x);
283 __profcxx_map2umap_insert(this->_M_map2umap_info,
284 size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
285 return iterator(__res,
this);
288 #if __cplusplus >= 201103L 290 insert(const_iterator __pos, value_type&& __x)
291 {
return iterator(_Base::insert(__pos.base(), std::move(__x)),
this); }
294 template<
typename _InputIterator>
296 insert(_InputIterator __first, _InputIterator __last)
298 for (; __first != __last; ++__first)
302 #if __cplusplus >= 201103L 305 { insert(__l.begin(), __l.end()); }
308 #if __cplusplus >= 201103L 310 erase(const_iterator __pos)
312 __profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
313 return iterator(_Base::erase(__pos.base()),
this);
317 erase(iterator __pos)
319 __profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
320 _Base::erase(__pos.base());
325 erase(
const key_type& __x)
327 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
328 __profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
329 return _Base::erase(__x);
332 #if __cplusplus >= 201103L 334 erase(const_iterator __first, const_iterator __last)
336 if (__first != __last)
339 for (; __first != __last;)
340 __ret = erase(__first++);
344 return iterator(_Base::erase(__first.base(), __last.base()),
this);
348 erase(iterator __first, iterator __last)
350 for (; __first != __last;)
356 clear() _GLIBCXX_NOEXCEPT
358 this->_M_profile_destruct();
360 this->_M_profile_construct();
364 count(
const key_type& __x)
const 366 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
367 return _Base::count(__x);
370 #if __cplusplus > 201103L 371 template<
typename _Kt,
373 typename __has_is_transparent<_Compare, _Kt>::type>
375 count(
const _Kt& __x)
const 377 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
378 return _Base::count(__x);
384 find(
const key_type& __x)
386 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
387 return iterator(_Base::find(__x),
this);
391 find(
const key_type& __x)
const 393 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
394 return const_iterator(_Base::find(__x),
this);
397 #if __cplusplus > 201103L 398 template<
typename _Kt,
400 typename __has_is_transparent<_Compare, _Kt>::type>
404 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
405 return { _Base::find(__x),
this };
408 template<
typename _Kt,
410 typename __has_is_transparent<_Compare, _Kt>::type>
412 find(
const _Kt& __x)
const 414 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
415 return { _Base::find(__x),
this };
420 lower_bound(
const key_type& __x)
422 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
423 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
424 return iterator(_Base::lower_bound(__x),
this);
428 lower_bound(
const key_type& __x)
const 430 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
431 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
432 return const_iterator(_Base::lower_bound(__x),
this);
435 #if __cplusplus > 201103L 436 template<
typename _Kt,
438 typename __has_is_transparent<_Compare, _Kt>::type>
440 lower_bound(
const _Kt& __x)
442 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
443 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
444 return { _Base::lower_bound(__x),
this };
447 template<
typename _Kt,
449 typename __has_is_transparent<_Compare, _Kt>::type>
451 lower_bound(
const _Kt& __x)
const 453 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
454 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
455 return { _Base::lower_bound(__x),
this };
460 upper_bound(
const key_type& __x)
462 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
463 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
464 return iterator(_Base::upper_bound(__x),
this);
468 upper_bound(
const key_type& __x)
const 470 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
471 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
472 return const_iterator(_Base::upper_bound(__x),
this);
475 #if __cplusplus > 201103L 476 template<
typename _Kt,
478 typename __has_is_transparent<_Compare, _Kt>::type>
480 upper_bound(
const _Kt& __x)
482 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
483 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
484 return { _Base::upper_bound(__x),
this };
487 template<
typename _Kt,
489 typename __has_is_transparent<_Compare, _Kt>::type>
491 upper_bound(
const _Kt& __x)
const 493 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
494 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
495 return { _Base::upper_bound(__x),
this };
500 equal_range(
const key_type& __x)
502 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
504 = _Base::equal_range(__x);
506 iterator(__base_ret.
second,
this));
510 equal_range(
const key_type& __x)
const 512 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
514 = _Base::equal_range(__x);
516 const_iterator(__base_ret.
second,
this));
519 #if __cplusplus > 201103L 520 template<
typename _Kt,
522 typename __has_is_transparent<_Compare, _Kt>::type>
524 equal_range(
const _Kt& __x)
526 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
527 auto __res = _Base::equal_range(__x);
528 return { { __res.first,
this }, { __res.second,
this } };
531 template<
typename _Kt,
533 typename __has_is_transparent<_Compare, _Kt>::type>
535 equal_range(
const _Kt& __x)
const 537 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
538 auto __res = _Base::equal_range(__x);
539 return { { __res.first,
this }, { __res.second,
this } };
544 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
547 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
557 _M_hint_used(_Base_const_iterator __hint, _Base_iterator __res)
559 return (__hint == __res
560 || (__hint == _M_base().end() && ++__res == _M_base().end())
561 || (__hint != _M_base().end() && (++__hint == __res
562 || ++__res == --__hint)));
565 template<
typename _K1,
typename _C1,
typename _A1>
569 template<
typename _K1,
typename _C1,
typename _A1>
574 template<
typename _Key,
typename _Compare,
typename _Allocator>
579 __profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
580 __profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
581 return __lhs._M_base() == __rhs._M_base();
584 template<
typename _Key,
typename _Compare,
typename _Allocator>
586 operator<(const set<_Key, _Compare, _Allocator>& __lhs,
589 __profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
590 __profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
591 return __lhs._M_base() < __rhs._M_base();
594 template<
typename _Key,
typename _Compare,
typename _Allocator>
598 {
return !(__lhs == __rhs); }
600 template<
typename _Key,
typename _Compare,
typename _Allocator>
602 operator<=(const set<_Key, _Compare, _Allocator>& __lhs,
604 {
return !(__rhs < __lhs); }
606 template<
typename _Key,
typename _Compare,
typename _Allocator>
610 {
return !(__lhs < __rhs); }
612 template<
typename _Key,
typename _Compare,
typename _Allocator>
616 {
return __rhs < __lhs; }
618 template<
typename _Key,
typename _Compare,
typename _Allocator>
622 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
623 {
return __x.swap(__y); }
_T2 second
first is a copy of the first object
Sequential helper functions. This file is a GNU profile extension to the Standard C++ Library...
Class std::set wrapper with performance instrumentation.
_T1 first
second_type is the second bound type
ISO C++ entities toplevel namespace is std.
constexpr pair< typename __decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2 >::__type > make_pair(_T1 &&__x, _T2 &&__y)
A convenience wrapper for creating a pair from two objects.
Struct holding two objects of arbitrary type.