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 template<
typename _InputIterator>
73 map(_InputIterator __first, _InputIterator __last,
74 const _Compare& __comp = _Compare(),
75 const _Allocator& __a = _Allocator())
76 :
_Base(__first, __last, __comp, __a)
77 { __profcxx_map_to_unordered_map_construct(
this); }
81 { __profcxx_map_to_unordered_map_construct(
this); }
85 { __profcxx_map_to_unordered_map_construct(
this); }
87 #ifdef __GXX_EXPERIMENTAL_CXX0X__
90 :
_Base(std::move(__x))
94 const _Compare& __c = _Compare(),
95 const allocator_type& __a = allocator_type())
96 :
_Base(__l, __c, __a) { }
99 ~
map() _GLIBCXX_NOEXCEPT
100 { __profcxx_map_to_unordered_map_destruct(
this); }
103 operator=(
const map& __x)
105 *
static_cast<_Base*
>(
this) = __x;
109 #ifdef __GXX_EXPERIMENTAL_CXX0X__
131 using _Base::get_allocator;
135 begin() _GLIBCXX_NOEXCEPT
136 {
return _Base::begin(); }
139 begin()
const _GLIBCXX_NOEXCEPT
140 {
return _Base::begin(); }
143 end() _GLIBCXX_NOEXCEPT
144 {
return _Base::end(); }
147 end()
const _GLIBCXX_NOEXCEPT
148 {
return _Base::end(); }
151 rbegin() _GLIBCXX_NOEXCEPT
153 __profcxx_map_to_unordered_map_invalidate(
this);
158 rbegin()
const _GLIBCXX_NOEXCEPT
160 __profcxx_map_to_unordered_map_invalidate(
this);
165 rend() _GLIBCXX_NOEXCEPT
167 __profcxx_map_to_unordered_map_invalidate(
this);
172 rend()
const _GLIBCXX_NOEXCEPT
174 __profcxx_map_to_unordered_map_invalidate(
this);
178 #ifdef __GXX_EXPERIMENTAL_CXX0X__
180 cbegin()
const noexcept
181 {
return const_iterator(_Base::begin()); }
184 cend()
const noexcept
185 {
return const_iterator(_Base::end()); }
188 crbegin()
const noexcept
190 __profcxx_map_to_unordered_map_invalidate(
this);
195 crend()
const noexcept
197 __profcxx_map_to_unordered_map_invalidate(
this);
205 using _Base::max_size;
209 operator[](
const key_type& __k)
211 __profcxx_map_to_unordered_map_find(
this,
size());
212 return _Base::operator[](__k);
215 #ifdef __GXX_EXPERIMENTAL_CXX0X__
217 operator[](key_type&& __k)
219 __profcxx_map_to_unordered_map_find(
this,
size());
220 return _Base::operator[](std::move(__k));
225 at(
const key_type& __k)
227 __profcxx_map_to_unordered_map_find(
this,
size());
228 return _Base::at(__k);
232 at(
const key_type& __k)
const
234 __profcxx_map_to_unordered_map_find(
this,
size());
235 return _Base::at(__k);
242 __profcxx_map_to_unordered_map_insert(
this,
size(), 1);
243 typedef typename _Base::iterator _Base_iterator;
249 #ifdef __GXX_EXPERIMENTAL_CXX0X__
250 template<
typename _Pair,
typename =
typename
252 _Pair&&>::value>::type>
256 __profcxx_map_to_unordered_map_insert(
this,
size(), 1);
257 typedef typename _Base::iterator _Base_iterator;
259 = _Base::insert(std::forward<_Pair>(__x));
265 #ifdef __GXX_EXPERIMENTAL_CXX0X__
269 size_type size_before =
size();
270 _Base::insert(__list);
271 __profcxx_map_to_unordered_map_insert(
this, size_before,
272 size() - size_before);
277 #ifdef __GXX_EXPERIMENTAL_CXX0X__
278 insert(const_iterator __position,
const value_type& __x)
280 insert(iterator __position,
const value_type& __x)
283 size_type size_before =
size();
284 iterator __i = iterator(_Base::insert(__position, __x));
285 __profcxx_map_to_unordered_map_insert(
this, size_before,
286 size() - size_before);
290 #ifdef __GXX_EXPERIMENTAL_CXX0X__
291 template<
typename _Pair,
typename =
typename
293 _Pair&&>::value>::type>
295 insert(const_iterator __position, _Pair&& __x)
297 size_type size_before =
size();
299 = iterator(_Base::insert(__position, std::forward<_Pair>(__x)));
300 __profcxx_map_to_unordered_map_insert(
this, size_before,
301 size() - size_before);
306 template<
typename _InputIterator>
308 insert(_InputIterator __first, _InputIterator __last)
310 size_type size_before =
size();
311 _Base::insert(__first, __last);
312 __profcxx_map_to_unordered_map_insert(
this, size_before,
313 size() - size_before);
316 #ifdef __GXX_EXPERIMENTAL_CXX0X__
318 erase(const_iterator __position)
320 iterator __i = _Base::erase(__position);
321 __profcxx_map_to_unordered_map_erase(
this,
size(), 1);
326 erase(iterator __position)
327 {
return erase(const_iterator(__position)); }
330 erase(iterator __position)
332 _Base::erase(__position);
333 __profcxx_map_to_unordered_map_erase(
this,
size(), 1);
338 erase(
const key_type& __x)
340 iterator __victim = find(__x);
341 if (__victim == end())
345 _Base::erase(__victim);
350 #ifdef __GXX_EXPERIMENTAL_CXX0X__
352 erase(const_iterator __first, const_iterator __last)
353 {
return iterator(_Base::erase(__first, __last)); }
356 erase(iterator __first, iterator __last)
357 { _Base::erase(__first, __last); }
362 { _Base::swap(__x); }
365 clear() _GLIBCXX_NOEXCEPT
366 { this->erase(begin(), end()); }
369 using _Base::key_comp;
370 using _Base::value_comp;
374 find(
const key_type& __x)
376 __profcxx_map_to_unordered_map_find(
this,
size());
377 return iterator(_Base::find(__x));
381 find(
const key_type& __x)
const
383 __profcxx_map_to_unordered_map_find(
this,
size());
384 return const_iterator(_Base::find(__x));
388 count(
const key_type& __x)
const
390 __profcxx_map_to_unordered_map_find(
this,
size());
391 return _Base::count(__x);
395 lower_bound(
const key_type& __x)
397 __profcxx_map_to_unordered_map_invalidate(
this);
398 return iterator(_Base::lower_bound(__x));
402 lower_bound(
const key_type& __x)
const
404 __profcxx_map_to_unordered_map_invalidate(
this);
405 return const_iterator(_Base::lower_bound(__x));
409 upper_bound(
const key_type& __x)
411 __profcxx_map_to_unordered_map_invalidate(
this);
412 return iterator(_Base::upper_bound(__x));
416 upper_bound(
const key_type& __x)
const
418 __profcxx_map_to_unordered_map_invalidate(
this);
419 return const_iterator(_Base::upper_bound(__x));
423 equal_range(
const key_type& __x)
425 typedef typename _Base::iterator _Base_iterator;
427 _Base::equal_range(__x);
433 equal_range(
const key_type& __x)
const
435 __profcxx_map_to_unordered_map_find(
this,
size());
436 typedef typename _Base::const_iterator _Base_const_iterator;
438 _Base::equal_range(__x);
440 const_iterator(__res.
second));
444 _M_base() _GLIBCXX_NOEXCEPT {
return *
this; }
447 _M_base()
const _GLIBCXX_NOEXCEPT {
return *
this; }
451 template<
typename _Key,
typename _Tp,
452 typename _Compare,
typename _Allocator>
457 __profcxx_map_to_unordered_map_invalidate(&__lhs);
458 __profcxx_map_to_unordered_map_invalidate(&__rhs);
459 return __lhs._M_base() == __rhs._M_base();
462 template<
typename _Key,
typename _Tp,
463 typename _Compare,
typename _Allocator>
468 __profcxx_map_to_unordered_map_invalidate(&__lhs);
469 __profcxx_map_to_unordered_map_invalidate(&__rhs);
470 return __lhs._M_base() != __rhs._M_base();
473 template<
typename _Key,
typename _Tp,
474 typename _Compare,
typename _Allocator>
476 operator<(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
477 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
479 __profcxx_map_to_unordered_map_invalidate(&__lhs);
480 __profcxx_map_to_unordered_map_invalidate(&__rhs);
481 return __lhs._M_base() < __rhs._M_base();
484 template<
typename _Key,
typename _Tp,
485 typename _Compare,
typename _Allocator>
487 operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
488 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
490 __profcxx_map_to_unordered_map_invalidate(&__lhs);
491 __profcxx_map_to_unordered_map_invalidate(&__rhs);
492 return __lhs._M_base() <= __rhs._M_base();
495 template<
typename _Key,
typename _Tp,
496 typename _Compare,
typename _Allocator>
498 operator>=(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
499 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
501 __profcxx_map_to_unordered_map_invalidate(&__lhs);
502 __profcxx_map_to_unordered_map_invalidate(&__rhs);
503 return __lhs._M_base() >= __rhs._M_base();
506 template<
typename _Key,
typename _Tp,
507 typename _Compare,
typename _Allocator>
509 operator>(
const map<_Key, _Tp, _Compare, _Allocator>& __lhs,
510 const map<_Key, _Tp, _Compare, _Allocator>& __rhs)
512 __profcxx_map_to_unordered_map_invalidate(&__lhs);
513 __profcxx_map_to_unordered_map_invalidate(&__rhs);
514 return __lhs._M_base() > __rhs._M_base();
517 template<
typename _Key,
typename _Tp,
518 typename _Compare,
typename _Allocator>
520 swap(map<_Key, _Tp, _Compare, _Allocator>& __lhs,
521 map<_Key, _Tp, _Compare, _Allocator>& __rhs)
522 { __lhs.swap(__rhs); }
_T1 first
second_type is the second bound type
_T2 second
first is a copy of the first object
Class std::map wrapper with performance instrumentation.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
Define a member typedef type only if a boolean constant is true.
Struct holding two objects of arbitrary type.
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.
Sequential helper functions. This file is a GNU profile extension to the Standard C++ Library...
is_nothrow_copy_constructible
constexpr size_t size() const _GLIBCXX_NOEXCEPT
Returns the total number of bits.