28 #ifndef _GLIBCXX_PROFILE_VECTOR
29 #define _GLIBCXX_PROFILE_VECTOR 1
36 namespace std _GLIBCXX_VISIBILITY(default)
40 template<
typename _Tp,
43 :
public _GLIBCXX_STD_C::vector<_Tp, _Allocator>
45 typedef _GLIBCXX_STD_C::vector<_Tp, _Allocator> _Base;
48 typedef typename _Base::reference reference;
49 typedef typename _Base::const_reference const_reference;
51 typedef __iterator_tracker<typename _Base::iterator, vector>
53 typedef __iterator_tracker<typename _Base::const_iterator, vector>
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;
67 _M_base() {
return *
this; }
70 _M_base()
const {
return *
this; }
74 vector(
const _Allocator& __a = _Allocator())
77 __profcxx_vector_construct(
this, this->capacity());
78 __profcxx_vector_construct2(
this);
81 #ifdef __GXX_EXPERIMENTAL_CXX0X__
86 __profcxx_vector_construct(
this, this->capacity());
87 __profcxx_vector_construct2(
this);
90 vector(size_type __n,
const _Tp& __value,
91 const _Allocator& __a = _Allocator())
92 : _Base(__n, __value, __a)
94 __profcxx_vector_construct(
this, this->capacity());
95 __profcxx_vector_construct2(
this);
99 vector(size_type __n,
const _Tp& __value = _Tp(),
100 const _Allocator& __a = _Allocator())
101 : _Base(__n, __value, __a)
103 __profcxx_vector_construct(
this, this->capacity());
104 __profcxx_vector_construct2(
this);
108 template<
class _InputIterator>
109 vector(_InputIterator __first, _InputIterator __last,
110 const _Allocator& __a = _Allocator())
111 : _Base(__first, __last, __a)
113 __profcxx_vector_construct(
this, this->capacity());
114 __profcxx_vector_construct2(
this);
117 vector(
const vector& __x)
120 __profcxx_vector_construct(
this, this->capacity());
121 __profcxx_vector_construct2(
this);
125 vector(
const _Base& __x)
128 __profcxx_vector_construct(
this, this->capacity());
129 __profcxx_vector_construct2(
this);
132 #ifdef __GXX_EXPERIMENTAL_CXX0X__
134 : _Base(std::move(__x))
136 __profcxx_vector_construct(
this, this->capacity());
137 __profcxx_vector_construct2(
this);
140 vector(initializer_list<value_type> __l,
141 const allocator_type& __a = allocator_type())
142 : _Base(__l, __a) { }
146 __profcxx_vector_destruct(
this, this->capacity(), this->
size());
147 __profcxx_vector_destruct2(
this);
151 operator=(
const vector& __x)
153 static_cast<_Base&
>(*this) = __x;
157 #ifdef __GXX_EXPERIMENTAL_CXX0X__
159 operator=(vector&& __x)
169 operator=(initializer_list<value_type> __l)
171 static_cast<_Base&
>(*this) = __l;
177 using _Base::get_allocator;
195 {
return const_iterator(
_Base::end(),
this); }
199 {
return reverse_iterator(
end()); }
201 const_reverse_iterator
203 {
return const_reverse_iterator(
end()); }
207 {
return reverse_iterator(
begin()); }
209 const_reverse_iterator
211 {
return const_reverse_iterator(
begin()); }
213 #ifdef __GXX_EXPERIMENTAL_CXX0X__
220 {
return const_iterator(
_Base::end(),
this); }
222 const_reverse_iterator
224 {
return const_reverse_iterator(
end()); }
226 const_reverse_iterator
228 {
return const_reverse_iterator(
begin()); }
233 using _Base::max_size;
235 #ifdef __GXX_EXPERIMENTAL_CXX0X__
237 resize(size_type __sz)
239 __profcxx_vector_invalid_operator(
this);
240 _M_profile_resize(
this, this->capacity(), __sz);
245 resize(size_type __sz,
const _Tp& __c)
247 __profcxx_vector_invalid_operator(
this);
248 _M_profile_resize(
this, this->capacity(), __sz);
249 _Base::resize(__sz, __c);
253 resize(size_type __sz, _Tp __c = _Tp())
255 __profcxx_vector_invalid_operator(
this);
256 _M_profile_resize(
this, this->capacity(), __sz);
257 _Base::resize(__sz, __c);
261 #ifdef __GXX_EXPERIMENTAL_CXX0X__
262 using _Base::shrink_to_fit;
271 __profcxx_vector_invalid_operator(
this);
272 return _M_base()[__n];
277 __profcxx_vector_invalid_operator(
this);
278 return _M_base()[__n];
286 return _Base::front();
292 return _Base::front();
298 return _Base::back();
304 return _Base::back();
313 push_back(
const _Tp& __x)
315 size_type __old_size = this->capacity();
316 _Base::push_back(__x);
317 _M_profile_resize(
this, __old_size, this->capacity());
320 #ifdef __GXX_EXPERIMENTAL_CXX0X__
324 size_type __old_size = this->capacity();
325 _Base::push_back(__x);
326 _M_profile_resize(
this, __old_size, this->capacity());
332 insert(iterator __position,
const _Tp& __x)
334 __profcxx_vector_insert(
this, __position.base() -
_Base::begin(),
336 size_type __old_size = this->capacity();
337 typename _Base::iterator __res = _Base::insert(__position.base(), __x);
338 _M_profile_resize(
this, __old_size, this->capacity());
339 return iterator(__res,
this);
342 #ifdef __GXX_EXPERIMENTAL_CXX0X__
344 insert(iterator __position, _Tp&& __x)
346 __profcxx_vector_insert(
this, __position.base() -
_Base::begin(),
348 size_type __old_size = this->capacity();
349 typename _Base::iterator __res = _Base::insert(__position.base(), __x);
350 _M_profile_resize(
this, __old_size, this->capacity());
351 return iterator(__res,
this);
355 insert(iterator __position, initializer_list<value_type> __l)
356 { this->insert(__position, __l.begin(), __l.end()); }
359 #ifdef __GXX_EXPERIMENTAL_CXX0X__
374 insert(iterator __position, size_type __n,
const _Tp& __x)
376 __profcxx_vector_insert(
this, __position.base() -
_Base::begin(),
378 size_type __old_size = this->capacity();
379 _Base::insert(__position, __n, __x);
380 _M_profile_resize(
this, __old_size, this->capacity());
383 template<
class _InputIterator>
385 insert(iterator __position,
386 _InputIterator __first, _InputIterator __last)
388 __profcxx_vector_insert(
this, __position.base()-
_Base::begin(),
390 size_type __old_size = this->capacity();
391 _Base::insert(__position, __first, __last);
392 _M_profile_resize(
this, __old_size, this->capacity());
397 erase(iterator __position)
399 typename _Base::iterator __res = _Base::erase(__position.base());
400 return iterator(__res,
this);
404 erase(iterator __first, iterator __last)
408 typename _Base::iterator __res = _Base::erase(__first.base(),
410 return iterator(__res,
this);
416 __profcxx_vector_destruct(
this, this->capacity(), this->
size());
417 __profcxx_vector_destruct2(
this);
421 inline void _M_profile_find()
const
423 __profcxx_vector_find(
this,
size());
426 inline void _M_profile_iterate(
int __rewind = 0)
const
428 __profcxx_vector_iterate(
this);
432 void _M_profile_resize(
void* obj, size_type __old_size,
433 size_type __new_size)
435 if (__old_size < __new_size) {
436 __profcxx_vector_resize(
this, this->
size(), __new_size);
437 __profcxx_vector_resize2(
this, this->
size(), __new_size);
442 template<
typename _Tp,
typename _Alloc>
444 operator==(
const vector<_Tp, _Alloc>& __lhs,
445 const vector<_Tp, _Alloc>& __rhs)
446 {
return __lhs._M_base() == __rhs._M_base(); }
448 template<
typename _Tp,
typename _Alloc>
450 operator!=(
const vector<_Tp, _Alloc>& __lhs,
451 const vector<_Tp, _Alloc>& __rhs)
452 {
return __lhs._M_base() != __rhs._M_base(); }
454 template<
typename _Tp,
typename _Alloc>
456 operator<(const vector<_Tp, _Alloc>& __lhs,
457 const vector<_Tp, _Alloc>& __rhs)
458 {
return __lhs._M_base() < __rhs._M_base(); }
460 template<
typename _Tp,
typename _Alloc>
462 operator<=(const vector<_Tp, _Alloc>& __lhs,
463 const vector<_Tp, _Alloc>& __rhs)
464 {
return __lhs._M_base() <= __rhs._M_base(); }
466 template<
typename _Tp,
typename _Alloc>
468 operator>=(
const vector<_Tp, _Alloc>& __lhs,
469 const vector<_Tp, _Alloc>& __rhs)
470 {
return __lhs._M_base() >= __rhs._M_base(); }
472 template<
typename _Tp,
typename _Alloc>
474 operator>(
const vector<_Tp, _Alloc>& __lhs,
475 const vector<_Tp, _Alloc>& __rhs)
476 {
return __lhs._M_base() > __rhs._M_base(); }
478 template<
typename _Tp,
typename _Alloc>
480 swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>& __rhs)
481 { __lhs.swap(__rhs); }
483 #ifdef __GXX_EXPERIMENTAL_CXX0X__
484 template<
typename _Tp,
typename _Alloc>
486 swap(vector<_Tp, _Alloc>&& __lhs, vector<_Tp, _Alloc>& __rhs)
487 { __lhs.swap(__rhs); }
489 template<
typename _Tp,
typename _Alloc>
491 swap(vector<_Tp, _Alloc>& __lhs, vector<_Tp, _Alloc>&& __rhs)
492 { __lhs.swap(__rhs); }
497 #ifdef __GXX_EXPERIMENTAL_CXX0X__
500 template<
typename _Alloc>
502 :
public __hash_base<size_t, __profile::vector<bool, _Alloc>>
505 operator()(
const __profile::vector<bool, _Alloc>& __b)
const
reference operator[](size_t __position)
Array-indexing support.
constexpr const _Tp * begin(initializer_list< _Tp > __ils)
Return an iterator pointing to the first element of the initilizer_list.
Primary class template hash.
constexpr size_t size() const
Returns the total number of bits.
Sequential helper functions. This file is a GNU profile extension to the Standard C++ Library...
constexpr const _Tp * end(initializer_list< _Tp > __ils)
Return an iterator pointing to one past the last element of the initilizer_list.
A standard container which offers fixed time access to individual elements in any order...
The standard allocator, as per [20.4].Further details: http://gcc.gnu.org/onlinedocs/libstdc++/manual...