29 #ifndef _GLIBCXX_PROFILE_MULTISET_H 30 #define _GLIBCXX_PROFILE_MULTISET_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::multiset<_Key, _Compare, _Allocator>,
44 public _Ordered_profile<multiset<_Key, _Compare, _Allocator> >
46 typedef _GLIBCXX_STD_C::multiset<_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 _Allocator allocator_type;
58 typedef typename _Base::reference reference;
59 typedef typename _Base::const_reference const_reference;
61 typedef __iterator_tracker<_Base_iterator,
63 typedef __iterator_tracker<_Base_const_iterator,
68 typedef typename _Base::size_type size_type;
69 typedef typename _Base::difference_type difference_type;
73 #if __cplusplus < 201103L 86 explicit multiset(
const _Compare& __comp,
87 const _Allocator& __a = _Allocator())
88 : _Base(__comp, __a) { }
90 #if __cplusplus >= 201103L 91 template<
typename _InputIterator,
92 typename = std::_RequireInputIter<_InputIterator>>
94 template<
typename _InputIterator>
96 multiset(_InputIterator __first, _InputIterator __last,
97 const _Compare& __comp = _Compare(),
98 const _Allocator& __a = _Allocator())
99 : _Base(__first, __last, __comp, __a) { }
101 #if __cplusplus >= 201103L 103 const _Compare& __comp = _Compare(),
104 const allocator_type& __a = allocator_type())
105 : _Base(__l, __comp, __a) { }
108 multiset(
const allocator_type& __a)
111 multiset(
const multiset& __x,
const allocator_type& __a)
112 : _Base(__x, __a) { }
114 multiset(multiset&& __x,
const allocator_type& __a)
115 noexcept( noexcept(_Base(std::move(__x), __a)) )
116 : _Base(std::move(__x), __a) { }
119 : _Base(__l, __a) { }
121 template<
typename _InputIterator>
122 multiset(_InputIterator __first, _InputIterator __last,
123 const allocator_type& __a)
124 : _Base(__first, __last, __a) { }
127 multiset(
const _Base& __x)
130 #if __cplusplus < 201103L 132 operator=(
const multiset& __x)
134 this->_M_profile_destruct();
136 this->_M_profile_construct();
141 operator=(
const multiset&) =
default;
144 operator=(multiset&&) =
default;
149 this->_M_profile_destruct();
151 this->_M_profile_construct();
158 begin() _GLIBCXX_NOEXCEPT
159 {
return iterator(_Base::begin(),
this); }
162 begin()
const _GLIBCXX_NOEXCEPT
163 {
return const_iterator(_Base::begin(),
this); }
166 end() _GLIBCXX_NOEXCEPT
167 {
return iterator(_Base::end(),
this); }
170 end()
const _GLIBCXX_NOEXCEPT
171 {
return const_iterator(_Base::end(),
this); }
173 #if __cplusplus >= 201103L 175 cbegin()
const noexcept
176 {
return const_iterator(_Base::cbegin(),
this); }
179 cend()
const noexcept
180 {
return const_iterator(_Base::cend(),
this); }
184 rbegin() _GLIBCXX_NOEXCEPT
186 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
187 return reverse_iterator(end());
190 const_reverse_iterator
191 rbegin()
const _GLIBCXX_NOEXCEPT
193 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
194 return const_reverse_iterator(end());
198 rend() _GLIBCXX_NOEXCEPT
200 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
201 return reverse_iterator(begin());
204 const_reverse_iterator
205 rend()
const _GLIBCXX_NOEXCEPT
207 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
208 return const_reverse_iterator(begin());
211 #if __cplusplus >= 201103L 212 const_reverse_iterator
213 crbegin()
const noexcept
215 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
216 return const_reverse_iterator(cend());
219 const_reverse_iterator
220 crend()
const noexcept
222 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
223 return const_reverse_iterator(cbegin());
229 _GLIBCXX_NOEXCEPT_IF( noexcept(declval<_Base&>().swap(__x)) )
236 #if __cplusplus >= 201103L 237 template<
typename... _Args>
239 emplace(_Args&&... __args)
243 __profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
244 return iterator(_Base::emplace(std::forward<_Args>(__args)...),
this);
247 template<
typename... _Args>
249 emplace_hint(const_iterator __pos, _Args&&... __args)
251 auto size_before = this->size();
253 = _Base::emplace_hint(__pos.base(), std::forward<_Args>(__args)...);
254 __profcxx_map2umap_insert(this->_M_map2umap_info,
255 size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
256 return iterator(__res,
this);
261 insert(
const value_type& __x)
263 __profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
264 return iterator(_Base::insert(__x),
this);
267 #if __cplusplus >= 201103L 269 insert(value_type&& __x)
271 __profcxx_map2umap_insert(this->_M_map2umap_info, this->size(), 1);
272 return iterator(_Base::insert(std::move(__x)),
this);
277 insert(const_iterator __pos,
const value_type& __x)
279 size_type size_before = this->size();
280 _Base_iterator __res = _Base::insert(__pos.base(), __x);
282 __profcxx_map2umap_insert(this->_M_map2umap_info,
283 size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
284 return iterator(__res,
this);
287 #if __cplusplus >= 201103L 289 insert(const_iterator __pos, value_type&& __x)
291 auto size_before = this->size();
292 auto __res = _Base::insert(__pos.base(), std::move(__x));
293 __profcxx_map2umap_insert(this->_M_map2umap_info,
294 size_before, _M_hint_used(__pos.base(), __res) ? 0 : 1);
295 return iterator(__res,
this);
299 #if __cplusplus >= 201103L 300 template<
typename _InputIterator,
301 typename = std::_RequireInputIter<_InputIterator>>
303 template<
typename _InputIterator>
306 insert(_InputIterator __first, _InputIterator __last)
308 for (; __first != __last; ++__first)
312 #if __cplusplus >= 201103L 315 { insert(__l.begin(), __l.end()); }
318 #if __cplusplus >= 201103L 320 erase(const_iterator __pos)
322 __profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
323 return iterator(_Base::erase(__pos.base()),
this);
327 erase(iterator __pos)
329 __profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
330 _Base::erase(__pos.base());
335 erase(
const key_type& __x)
337 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
338 __profcxx_map2umap_erase(this->_M_map2umap_info, this->size(), 1);
339 return _Base::erase(__x);
342 #if __cplusplus >= 201103L 344 erase(const_iterator __first, const_iterator __last)
346 if (__first != __last)
349 for (; __first != __last;)
350 __ret = erase(__first++);
354 return iterator(_Base::erase(__first.base(), __last.base()),
this);
358 erase(iterator __first, iterator __last)
360 for (; __first != __last;)
366 clear() _GLIBCXX_NOEXCEPT
368 this->_M_profile_destruct();
370 this->_M_profile_construct();
374 count(
const key_type& __x)
const 376 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
377 return _Base::count(__x);
380 #if __cplusplus > 201103L 381 template<
typename _Kt,
383 typename __has_is_transparent<_Compare, _Kt>::type>
385 count(
const _Kt& __x)
const 387 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
388 return _Base::count(__x);
394 find(
const key_type& __x)
396 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
397 return iterator(_Base::find(__x),
this);
403 find(
const key_type& __x)
const 405 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
406 return const_iterator(_Base::find(__x),
this);
409 #if __cplusplus > 201103L 410 template<
typename _Kt,
412 typename __has_is_transparent<_Compare, _Kt>::type>
416 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
417 return { _Base::find(__x),
this };
420 template<
typename _Kt,
422 typename __has_is_transparent<_Compare, _Kt>::type>
424 find(
const _Kt& __x)
const 426 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
427 return { _Base::find(__x),
this };
432 lower_bound(
const key_type& __x)
434 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
435 return iterator(_Base::lower_bound(__x),
this);
441 lower_bound(
const key_type& __x)
const 443 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
444 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
445 return const_iterator(_Base::lower_bound(__x),
this);
448 #if __cplusplus > 201103L 449 template<
typename _Kt,
451 typename __has_is_transparent<_Compare, _Kt>::type>
453 lower_bound(
const _Kt& __x)
455 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
456 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
457 return { _Base::lower_bound(__x),
this };
460 template<
typename _Kt,
462 typename __has_is_transparent<_Compare, _Kt>::type>
464 lower_bound(
const _Kt& __x)
const 466 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
467 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
468 return { _Base::lower_bound(__x),
this };
473 upper_bound(
const key_type& __x)
475 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
476 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
477 return iterator(_Base::upper_bound(__x),
this);
483 upper_bound(
const key_type& __x)
const 485 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
486 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
487 return const_iterator(_Base::upper_bound(__x),
this);
490 #if __cplusplus > 201103L 491 template<
typename _Kt,
493 typename __has_is_transparent<_Compare, _Kt>::type>
495 upper_bound(
const _Kt& __x)
497 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
498 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
499 return { _Base::upper_bound(__x),
this };
502 template<
typename _Kt,
504 typename __has_is_transparent<_Compare, _Kt>::type>
506 upper_bound(
const _Kt& __x)
const 508 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
509 __profcxx_map2umap_invalidate(this->_M_map2umap_info);
510 return { _Base::upper_bound(__x),
this };
515 equal_range(
const key_type& __x)
517 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
519 = _Base::equal_range(__x);
521 iterator(__base_ret.
second,
this));
527 equal_range(
const key_type& __x)
const 529 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
531 = _Base::equal_range(__x);
533 const_iterator(__base_ret.
second,
this));
536 #if __cplusplus > 201103L 537 template<
typename _Kt,
539 typename __has_is_transparent<_Compare, _Kt>::type>
541 equal_range(
const _Kt& __x)
543 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
544 auto __res = _Base::equal_range(__x);
545 return { { __res.first,
this }, { __res.second,
this } };
548 template<
typename _Kt,
550 typename __has_is_transparent<_Compare, _Kt>::type>
552 equal_range(
const _Kt& __x)
const 554 __profcxx_map2umap_find(this->_M_map2umap_info, this->size());
555 auto __res = _Base::equal_range(__x);
556 return { { __res.first,
this }, { __res.second,
this } };
561 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
564 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
574 _M_hint_used(_Base_const_iterator __hint, _Base_iterator __res)
576 return (__hint == __res
577 || (__hint == _M_base().end() && ++__res == _M_base().end())
578 || (__hint != _M_base().end() && (++__hint == __res
579 || ++__res == --__hint)));
582 template<
typename _K1,
typename _C1,
typename _A1>
587 template<
typename _K1,
typename _C1,
typename _A1>
589 operator< (const multiset<_K1, _C1, _A1>&,
593 template<
typename _Key,
typename _Compare,
typename _Allocator>
598 __profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
599 __profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
600 return __lhs._M_base() == __rhs._M_base();
603 template<
typename _Key,
typename _Compare,
typename _Allocator>
605 operator<(const multiset<_Key, _Compare, _Allocator>& __lhs,
608 __profcxx_map2umap_invalidate(__lhs._M_map2umap_info);
609 __profcxx_map2umap_invalidate(__rhs._M_map2umap_info);
610 return __lhs._M_base() < __rhs._M_base();
613 template<
typename _Key,
typename _Compare,
typename _Allocator>
617 {
return !(__lhs == __rhs); }
619 template<
typename _Key,
typename _Compare,
typename _Allocator>
621 operator<=(const multiset<_Key, _Compare, _Allocator>& __lhs,
623 {
return !(__rhs < __lhs); }
625 template<
typename _Key,
typename _Compare,
typename _Allocator>
629 {
return !(__lhs < __rhs); }
631 template<
typename _Key,
typename _Compare,
typename _Allocator>
635 {
return __rhs < __lhs; }
637 template<
typename _Key,
typename _Compare,
typename _Allocator>
641 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
642 {
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...
_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.
Class std::multiset wrapper with performance instrumentation.
Struct holding two objects of arbitrary type.