28 #ifndef _GLIBCXX_PROFILE_MAP_H
29 #define _GLIBCXX_PROFILE_MAP_H 1
34 namespace std _GLIBCXX_VISIBILITY(default)
39 template<
typename _Key,
typename _Tp,
typename _Compare = std::less<_Key>,
40 typename _Allocator = std::allocator<std::pair<const _Key, _Tp> > >
42 :
public _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator>
44 typedef _GLIBCXX_STD_C::map<_Key, _Tp, _Compare, _Allocator>
_Base;
48 typedef _Key key_type;
49 typedef _Tp mapped_type;
51 typedef _Compare key_compare;
52 typedef _Allocator allocator_type;
53 typedef typename _Base::reference reference;
54 typedef typename _Base::const_reference const_reference;
56 typedef typename _Base::iterator iterator;
57 typedef typename _Base::const_iterator const_iterator;
58 typedef typename _Base::size_type size_type;
59 typedef typename _Base::difference_type difference_type;
60 typedef typename _Base::pointer pointer;
61 typedef typename _Base::const_pointer const_pointer;
67 map(
const _Compare& __comp = _Compare(),
68 const _Allocator& __a = _Allocator())
70 { __profcxx_map_to_unordered_map_construct(
this); }
72 #if __cplusplus >= 201103L
73 template<
typename _InputIterator,
74 typename = std::_RequireInputIter<_InputIterator>>
76 template<
typename _InputIterator>
78 map(_InputIterator __first, _InputIterator __last,
79 const _Compare& __comp = _Compare(),
80 const _Allocator& __a = _Allocator())
81 : _Base(__first, __last, __comp, __a)
82 { __profcxx_map_to_unordered_map_construct(
this); }
86 { __profcxx_map_to_unordered_map_construct(
this); }
90 { __profcxx_map_to_unordered_map_construct(
this); }
92 #if __cplusplus >= 201103L
94 noexcept(is_nothrow_copy_constructible<_Compare>::value)
98 map(initializer_list<value_type> __l,
99 const _Compare& __c = _Compare(),
100 const allocator_type& __a = allocator_type())
101 : _Base(__l, __c, __a) { }
104 ~map() _GLIBCXX_NOEXCEPT
105 { __profcxx_map_to_unordered_map_destruct(
this); }
108 operator=(
const map& __x)
110 *
static_cast<_Base*
>(
this) = __x;
114 #if __cplusplus >= 201103L
126 operator=(initializer_list<value_type> __l)
136 using _Base::get_allocator;
140 begin() _GLIBCXX_NOEXCEPT
141 {
return _Base::begin(); }
144 begin()
const _GLIBCXX_NOEXCEPT
145 {
return _Base::begin(); }
148 end() _GLIBCXX_NOEXCEPT
149 {
return _Base::end(); }
152 end()
const _GLIBCXX_NOEXCEPT
153 {
return _Base::end(); }
156 rbegin() _GLIBCXX_NOEXCEPT
158 __profcxx_map_to_unordered_map_invalidate(
this);
159 return reverse_iterator(end());
162 const_reverse_iterator
163 rbegin()
const _GLIBCXX_NOEXCEPT
165 __profcxx_map_to_unordered_map_invalidate(
this);
166 return const_reverse_iterator(end());
170 rend() _GLIBCXX_NOEXCEPT
172 __profcxx_map_to_unordered_map_invalidate(
this);
173 return reverse_iterator(begin());
176 const_reverse_iterator
177 rend()
const _GLIBCXX_NOEXCEPT
179 __profcxx_map_to_unordered_map_invalidate(
this);
180 return const_reverse_iterator(begin());
183 #if __cplusplus >= 201103L
185 cbegin()
const noexcept
186 {
return const_iterator(_Base::begin()); }
189 cend()
const noexcept
190 {
return const_iterator(_Base::end()); }
192 const_reverse_iterator
193 crbegin()
const noexcept
195 __profcxx_map_to_unordered_map_invalidate(
this);
196 return const_reverse_iterator(end());
199 const_reverse_iterator
200 crend()
const noexcept
202 __profcxx_map_to_unordered_map_invalidate(
this);
203 return const_reverse_iterator(begin());
210 using _Base::max_size;
214 operator[](
const key_type& __k)
216 __profcxx_map_to_unordered_map_find(
this, size());
217 return _Base::operator[](__k);
220 #if __cplusplus >= 201103L
222 operator[](key_type&& __k)
224 __profcxx_map_to_unordered_map_find(
this, size());
225 return _Base::operator[](
std::move(__k));
230 at(
const key_type& __k)
232 __profcxx_map_to_unordered_map_find(
this, size());
233 return _Base::at(__k);
237 at(
const key_type& __k)
const
239 __profcxx_map_to_unordered_map_find(
this, size());
240 return _Base::at(__k);
244 #if __cplusplus >= 201103L
245 template<
typename... _Args>
247 emplace(_Args&&... __args)
249 __profcxx_map_to_unordered_map_insert(
this, size(), 1);
250 auto __res = _Base::emplace(std::forward<_Args>(__args)...);
255 template<
typename... _Args>
257 emplace_hint(const_iterator __pos, _Args&&... __args)
259 size_type size_before = size();
260 auto __res = _Base::emplace_hint(__pos,
261 std::forward<_Args>(__args)...);
262 __profcxx_map_to_unordered_map_insert(
this, size_before,
263 size() - size_before);
269 insert(
const value_type& __x)
271 __profcxx_map_to_unordered_map_insert(
this, size(), 1);
272 typedef typename _Base::iterator _Base_iterator;
278 #if __cplusplus >= 201103L
279 template<
typename _Pair,
typename =
typename
280 std::enable_if<std::is_constructible<value_type,
281 _Pair&&>::value>::type>
285 __profcxx_map_to_unordered_map_insert(
this, size(), 1);
286 typedef typename _Base::iterator _Base_iterator;
288 = _Base::insert(std::forward<_Pair>(__x));
294 #if __cplusplus >= 201103L
296 insert(std::initializer_list<value_type> __list)
298 size_type size_before = size();
299 _Base::insert(__list);
300 __profcxx_map_to_unordered_map_insert(
this, size_before,
301 size() - size_before);
306 #if __cplusplus >= 201103L
307 insert(const_iterator __position,
const value_type& __x)
309 insert(iterator __position,
const value_type& __x)
312 size_type size_before = size();
313 iterator __i = iterator(_Base::insert(__position, __x));
314 __profcxx_map_to_unordered_map_insert(
this, size_before,
315 size() - size_before);
319 #if __cplusplus >= 201103L
320 template<
typename _Pair,
typename =
typename
321 std::enable_if<std::is_constructible<value_type,
322 _Pair&&>::value>::type>
324 insert(const_iterator __position, _Pair&& __x)
326 size_type size_before = size();
328 = iterator(_Base::insert(__position, std::forward<_Pair>(__x)));
329 __profcxx_map_to_unordered_map_insert(
this, size_before,
330 size() - size_before);
335 #if __cplusplus >= 201103L
336 template<
typename _InputIterator,
337 typename = std::_RequireInputIter<_InputIterator>>
339 template<
typename _InputIterator>
342 insert(_InputIterator __first, _InputIterator __last)
344 size_type size_before = size();
345 _Base::insert(__first, __last);
346 __profcxx_map_to_unordered_map_insert(
this, size_before,
347 size() - size_before);
350 #if __cplusplus >= 201103L
352 erase(const_iterator __position)
354 iterator __i = _Base::erase(__position);
355 __profcxx_map_to_unordered_map_erase(
this, size(), 1);
360 erase(iterator __position)
361 {
return erase(const_iterator(__position)); }
364 erase(iterator __position)
366 _Base::erase(__position);
367 __profcxx_map_to_unordered_map_erase(
this, size(), 1);
372 erase(
const key_type& __x)
374 iterator __victim = find(__x);
375 if (__victim == end())
379 _Base::erase(__victim);
384 #if __cplusplus >= 201103L
386 erase(const_iterator __first, const_iterator __last)
387 {
return iterator(_Base::erase(__first, __last)); }
390 erase(iterator __first, iterator __last)
391 { _Base::erase(__first, __last); }
396 { _Base::swap(__x); }
399 clear() _GLIBCXX_NOEXCEPT
400 { this->erase(begin(), end()); }
403 using _Base::key_comp;
404 using _Base::value_comp;
408 find(
const key_type& __x)
410 __profcxx_map_to_unordered_map_find(
this, size());
411 return iterator(_Base::find(__x));
415 find(
const key_type& __x)
const
417 __profcxx_map_to_unordered_map_find(
this, size());
418 return const_iterator(_Base::find(__x));
422 count(
const key_type& __x)
const
424 __profcxx_map_to_unordered_map_find(
this, size());
425 return _Base::count(__x);
429 lower_bound(
const key_type& __x)
431 __profcxx_map_to_unordered_map_invalidate(
this);
432 return iterator(_Base::lower_bound(__x));
436 lower_bound(
const key_type& __x)
const
438 __profcxx_map_to_unordered_map_invalidate(
this);
439 return const_iterator(_Base::lower_bound(__x));
443 upper_bound(
const key_type& __x)
445 __profcxx_map_to_unordered_map_invalidate(
this);
446 return iterator(_Base::upper_bound(__x));
450 upper_bound(
const key_type& __x)
const
452 __profcxx_map_to_unordered_map_invalidate(
this);
453 return const_iterator(_Base::upper_bound(__x));
457 equal_range(
const key_type& __x)
459 typedef typename _Base::iterator _Base_iterator;
461 _Base::equal_range(__x);
467 equal_range(
const key_type& __x)
const
469 __profcxx_map_to_unordered_map_find(
this, size());
470 typedef typename _Base::const_iterator _Base_const_iterator;
472 _Base::equal_range(__x);
474 const_iterator(__res.
second));
478 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
481 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
485 template<
typename _Key,
typename _Tp,
486 typename _Compare,
typename _Allocator>
491 __profcxx_map_to_unordered_map_invalidate(&__lhs);
492 __profcxx_map_to_unordered_map_invalidate(&__rhs);
493 return __lhs._M_base() == __rhs._M_base();
496 template<
typename _Key,
typename _Tp,
497 typename _Compare,
typename _Allocator>
502 __profcxx_map_to_unordered_map_invalidate(&__lhs);
503 __profcxx_map_to_unordered_map_invalidate(&__rhs);
504 return __lhs._M_base() != __rhs._M_base();
507 template<
typename _Key,
typename _Tp,
508 typename _Compare,
typename _Allocator>
510 operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
511 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
513 __profcxx_map_to_unordered_map_invalidate(&__lhs);
514 __profcxx_map_to_unordered_map_invalidate(&__rhs);
515 return __lhs._M_base() < __rhs._M_base();
518 template<
typename _Key,
typename _Tp,
519 typename _Compare,
typename _Allocator>
521 operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
522 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
524 __profcxx_map_to_unordered_map_invalidate(&__lhs);
525 __profcxx_map_to_unordered_map_invalidate(&__rhs);
526 return __lhs._M_base() <= __rhs._M_base();
529 template<
typename _Key,
typename _Tp,
530 typename _Compare,
typename _Allocator>
532 operator>=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
533 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
535 __profcxx_map_to_unordered_map_invalidate(&__lhs);
536 __profcxx_map_to_unordered_map_invalidate(&__rhs);
537 return __lhs._M_base() >= __rhs._M_base();
540 template<
typename _Key,
typename _Tp,
541 typename _Compare,
typename _Allocator>
543 operator>(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
544 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
546 __profcxx_map_to_unordered_map_invalidate(&__lhs);
547 __profcxx_map_to_unordered_map_invalidate(&__rhs);
548 return __lhs._M_base() > __rhs._M_base();
551 template<
typename _Key,
typename _Tp,
552 typename _Compare,
typename _Allocator>
554 swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
555 map<_Key, _Tp, _Compare, _Allocator>& __rhs)
556 { __lhs.swap(__rhs); }
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
Sequential helper functions. This file is a GNU profile extension to the Standard C++ Library...
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.
ISO C++ entities toplevel namespace is std.
_T1 first
second_type is the second bound type
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values.
Class std::map wrapper with performance instrumentation.
Struct holding two objects of arbitrary type.
_T2 second
first is a copy of the first object
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.