29 #ifndef _GLIBCXX_PROFILE_LIST
30 #define _GLIBCXX_PROFILE_LIST 1
36 namespace std _GLIBCXX_VISIBILITY(default)
41 template<
typename _Tp,
typename _Allocator = std::allocator<_Tp> >
43 :
public _GLIBCXX_STD_C::list<_Tp, _Allocator>
45 typedef _GLIBCXX_STD_C::list<_Tp, _Allocator>
_Base;
48 typedef typename _Base::reference reference;
49 typedef typename _Base::const_reference const_reference;
51 typedef __iterator_tracker<typename _Base::iterator, list>
53 typedef __iterator_tracker<typename _Base::const_iterator, list>
56 typedef typename _Base::size_type size_type;
57 typedef typename _Base::difference_type difference_type;
59 typedef _Tp value_type;
60 typedef _Allocator allocator_type;
61 typedef typename _Base::pointer pointer;
62 typedef typename _Base::const_pointer const_pointer;
68 list(
const _Allocator& __a = _Allocator()) _GLIBCXX_NOEXCEPT
71 __profcxx_list_construct(
this);
72 __profcxx_list_construct2(
this);
75 #if __cplusplus >= 201103L
80 __profcxx_list_construct(
this);
81 __profcxx_list_construct2(
this);
84 list(size_type __n,
const _Tp& __value,
85 const _Allocator& __a = _Allocator())
86 :
_Base(__n, __value, __a)
88 __profcxx_list_construct(
this);
89 __profcxx_list_construct2(
this);
93 list(size_type __n,
const _Tp& __value = _Tp(),
94 const _Allocator& __a = _Allocator())
95 :
_Base(__n, __value, __a)
97 __profcxx_list_construct(
this);
98 __profcxx_list_construct2(
this);
102 #if __cplusplus >= 201103L
103 template<
typename _InputIterator,
104 typename = std::_RequireInputIter<_InputIterator>>
106 template<
class _InputIterator>
108 list(_InputIterator __first, _InputIterator __last,
109 const _Allocator& __a = _Allocator())
110 :
_Base(__first, __last, __a)
112 __profcxx_list_construct(
this);
113 __profcxx_list_construct2(
this);
116 list(
const list& __x)
119 __profcxx_list_construct(
this);
120 __profcxx_list_construct2(
this);
123 list(
const _Base& __x)
126 __profcxx_list_construct(
this);
127 __profcxx_list_construct2(
this);
130 #if __cplusplus >= 201103L
131 list(list&& __x) noexcept
132 :
_Base(std::move(__x))
134 __profcxx_list_construct(
this);
135 __profcxx_list_construct2(
this);
139 const allocator_type& __a = allocator_type())
140 :
_Base(__l, __a) { }
143 ~list() _GLIBCXX_NOEXCEPT
145 __profcxx_list_destruct(
this);
146 __profcxx_list_destruct2(
this);
150 operator=(
const list& __x)
152 static_cast<_Base&
>(*this) = __x;
156 #if __cplusplus >= 201103L
158 operator=(list&& __x)
170 static_cast<_Base&
>(*this) = __l;
176 { _Base::assign(__l); }
179 #if __cplusplus >= 201103L
180 template<
typename _InputIterator,
181 typename = std::_RequireInputIter<_InputIterator>>
183 template<
class _InputIterator>
186 assign(_InputIterator __first, _InputIterator __last)
187 { _Base::assign(__first, __last); }
190 assign(size_type __n,
const _Tp& __t)
191 { _Base::assign(__n, __t); }
193 using _Base::get_allocator;
197 begin() _GLIBCXX_NOEXCEPT
198 {
return iterator(_Base::begin(),
this); }
201 begin()
const _GLIBCXX_NOEXCEPT
202 {
return const_iterator(_Base::begin(),
this); }
205 end() _GLIBCXX_NOEXCEPT
207 __profcxx_list_rewind(
this);
208 return iterator(_Base::end(),
this);
212 end()
const _GLIBCXX_NOEXCEPT
214 __profcxx_list_rewind(
this);
215 return const_iterator(_Base::end(),
this);
219 rbegin() _GLIBCXX_NOEXCEPT
221 __profcxx_list_rewind(
this);
226 rbegin()
const _GLIBCXX_NOEXCEPT
228 __profcxx_list_rewind(
this);
233 rend() _GLIBCXX_NOEXCEPT
237 rend()
const _GLIBCXX_NOEXCEPT
240 #if __cplusplus >= 201103L
242 cbegin()
const noexcept
243 {
return const_iterator(_Base::begin(),
this); }
246 cend()
const noexcept
247 {
return const_iterator(_Base::end(),
this); }
250 crbegin()
const noexcept
254 crend()
const noexcept
261 using _Base::max_size;
263 #if __cplusplus >= 201103L
265 resize(size_type __sz)
266 { _Base::resize(__sz); }
269 resize(size_type __sz,
const _Tp& __c)
270 { _Base::resize(__sz, __c); }
273 resize(size_type __sz, _Tp __c = _Tp())
274 { _Base::resize(__sz, __c); }
279 front() _GLIBCXX_NOEXCEPT
280 {
return _Base::front(); }
283 front()
const _GLIBCXX_NOEXCEPT
284 {
return _Base::front(); }
287 back() _GLIBCXX_NOEXCEPT
289 __profcxx_list_rewind(
this);
290 return _Base::back();
294 back()
const _GLIBCXX_NOEXCEPT
296 __profcxx_list_rewind(
this);
297 return _Base::back();
302 push_front(
const value_type& __x)
304 __profcxx_list_invalid_operator(
this);
305 __profcxx_list_operation(
this);
306 _Base::push_front(__x);
309 #if __cplusplus >= 201103L
310 using _Base::emplace_front;
314 pop_front() _GLIBCXX_NOEXCEPT
316 __profcxx_list_operation(
this);
320 using _Base::push_back;
322 #if __cplusplus >= 201103L
323 using _Base::emplace_back;
327 pop_back() _GLIBCXX_NOEXCEPT
329 iterator __victim = end();
332 __profcxx_list_rewind(
this);
335 #if __cplusplus >= 201103L
336 template<
typename... _Args>
338 emplace(const_iterator __position, _Args&&... __args)
340 return iterator(_Base::emplace(__position.base(),
341 std::forward<_Args>(__args)...),
347 #if __cplusplus >= 201103L
348 insert(const_iterator __position,
const _Tp& __x)
350 insert(iterator __position,
const _Tp& __x)
353 _M_profile_insert(
this, __position,
size());
354 return iterator(_Base::insert(__position.base(), __x),
this);
357 #if __cplusplus >= 201103L
359 insert(const_iterator __position, _Tp&& __x)
361 _M_profile_insert(
this, __position,
size());
362 return iterator(_Base::emplace(__position.base(), std::move(__x)),
369 _M_profile_insert(
this, __position,
size());
370 return iterator(_Base::insert(__position.base(), __l),
this);
374 #if __cplusplus >= 201103L
376 insert(const_iterator __position, size_type __n,
const _Tp& __x)
378 _M_profile_insert(
this, __position,
size());
379 return iterator(_Base::insert(__position.base(), __n, __x),
this);
383 insert(iterator __position, size_type __n,
const _Tp& __x)
385 _M_profile_insert(
this, __position,
size());
386 _Base::insert(__position.base(), __n, __x);
390 #if __cplusplus >= 201103L
391 template<
typename _InputIterator,
392 typename = std::_RequireInputIter<_InputIterator>>
394 insert(const_iterator __position, _InputIterator __first,
395 _InputIterator __last)
397 _M_profile_insert(
this, __position,
size());
398 return iterator(_Base::insert(__position.base(), __first, __last),
402 template<
class _InputIterator>
404 insert(iterator __position, _InputIterator __first,
405 _InputIterator __last)
407 _M_profile_insert(
this, __position,
size());
408 _Base::insert(__position.base(), __first, __last);
413 #if __cplusplus >= 201103L
414 erase(const_iterator __position) noexcept
416 erase(iterator __position)
418 {
return iterator(_Base::erase(__position.base()),
this); }
421 #if __cplusplus >= 201103L
422 erase(const_iterator __position, const_iterator __last) noexcept
424 erase(iterator __position, iterator __last)
429 return iterator(_Base::erase(__position.base(), __last.base()),
this);
434 { _Base::swap(__x); }
437 clear() _GLIBCXX_NOEXCEPT
442 #if __cplusplus >= 201103L
443 splice(const_iterator __position, list&& __x) noexcept
445 splice(iterator __position, list& __x)
447 { this->splice(__position, _GLIBCXX_MOVE(__x), __x.begin(), __x.end()); }
449 #if __cplusplus >= 201103L
451 splice(const_iterator __position, list& __x) noexcept
452 { this->splice(__position, std::move(__x)); }
455 splice(const_iterator __position, list& __x, const_iterator __i)
456 { this->splice(__position, std::move(__x), __i); }
460 #if __cplusplus >= 201103L
461 splice(const_iterator __position, list&& __x, const_iterator __i) noexcept
463 splice(iterator __position, list& __x, iterator __i)
470 _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
475 #if __cplusplus >= 201103L
476 splice(const_iterator __position, list&& __x, const_iterator __first,
477 const_iterator __last) noexcept
479 splice(iterator __position, list& __x, iterator __first,
486 _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
487 __first.base(), __last.base());
490 #if __cplusplus >= 201103L
492 splice(const_iterator __position, list& __x,
493 const_iterator __first, const_iterator __last) noexcept
494 { this->splice(__position, std::move(__x), __first, __last); }
498 remove(
const _Tp& __value)
500 for (iterator __x = begin(); __x != end(); )
509 template<
class _Predicate>
511 remove_if(_Predicate __pred)
513 for (iterator __x = begin(); __x != end(); )
515 __profcxx_list_operation(
this);
526 iterator __first = begin();
527 iterator __last = end();
528 if (__first == __last)
530 iterator __next = __first;
531 while (++__next != __last)
533 __profcxx_list_operation(
this);
534 if (*__first == *__next)
542 template<
class _BinaryPredicate>
544 unique(_BinaryPredicate __binary_pred)
546 iterator __first = begin();
547 iterator __last = end();
548 if (__first == __last)
550 iterator __next = __first;
551 while (++__next != __last)
553 __profcxx_list_operation(
this);
554 if (__binary_pred(*__first, *__next))
563 #if __cplusplus >= 201103L
572 { _Base::merge(_GLIBCXX_MOVE(__x._M_base())); }
575 #if __cplusplus >= 201103L
578 { this->merge(std::move(__x)); }
581 template<
class _Compare>
583 #if __cplusplus >= 201103L
584 merge(list&& __x, _Compare __comp)
586 merge(list& __x, _Compare __comp)
592 { _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp); }
595 #if __cplusplus >= 201103L
596 template<
typename _Compare>
598 merge(list& __x, _Compare __comp)
599 { this->merge(std::move(__x), __comp); }
603 sort() { _Base::sort(); }
605 template<
typename _StrictWeakOrdering>
607 sort(_StrictWeakOrdering __pred) { _Base::sort(__pred); }
609 using _Base::reverse;
612 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
615 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
617 void _M_profile_find()
const
620 void _M_profile_iterate(
int __rewind = 0)
const
622 __profcxx_list_operation(
this);
623 __profcxx_list_iterate(
this);
625 __profcxx_list_rewind(
this);
630 _M_profile_insert(
void* obj, const_iterator __pos, size_type __size)
632 size_type __shift = 0;
633 typename _Base::const_iterator __it = __pos.base();
634 for (; __it != _Base::end(); ++__it)
636 __profcxx_list_rewind(
this);
637 __profcxx_list_operation(
this);
638 __profcxx_list_insert(
this, __shift, __size);
642 template<
typename _Tp,
typename _Alloc>
646 {
return __lhs._M_base() == __rhs._M_base(); }
648 template<
typename _Tp,
typename _Alloc>
652 {
return __lhs._M_base() != __rhs._M_base(); }
654 template<
typename _Tp,
typename _Alloc>
656 operator<(const list<_Tp, _Alloc>& __lhs,
657 const list<_Tp, _Alloc>& __rhs)
658 {
return __lhs._M_base() < __rhs._M_base(); }
660 template<
typename _Tp,
typename _Alloc>
662 operator<=(const list<_Tp, _Alloc>& __lhs,
663 const list<_Tp, _Alloc>& __rhs)
664 {
return __lhs._M_base() <= __rhs._M_base(); }
666 template<
typename _Tp,
typename _Alloc>
668 operator>=(
const list<_Tp, _Alloc>& __lhs,
669 const list<_Tp, _Alloc>& __rhs)
670 {
return __lhs._M_base() >= __rhs._M_base(); }
672 template<
typename _Tp,
typename _Alloc>
674 operator>(
const list<_Tp, _Alloc>& __lhs,
675 const list<_Tp, _Alloc>& __rhs)
676 {
return __lhs._M_base() > __rhs._M_base(); }
678 template<
typename _Tp,
typename _Alloc>
680 swap(list<_Tp, _Alloc>& __lhs, list<_Tp, _Alloc>& __rhs)
681 { __lhs.swap(__rhs); }
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
constexpr size_t size() const noexcept
Returns the total number of bits.
List wrapper with performance instrumentation.
void swap(function< _Res(_Args...)> &__x, function< _Res(_Args...)> &__y)
Swap the targets of two polymorphic function object wrappers.
Sequential helper functions. This file is a GNU profile extension to the Standard C++ Library...