61 #if __cplusplus >= 201103L
66 namespace std _GLIBCXX_VISIBILITY(default)
68 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
94 template <
typename _Key,
typename _Tp,
typename _Compare = std::less<_Key>,
95 typename _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
99 typedef _Key key_type;
100 typedef _Tp mapped_type;
102 typedef _Compare key_compare;
103 typedef _Alloc allocator_type;
107 typedef typename _Alloc::value_type _Alloc_value_type;
108 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
109 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
110 _BinaryFunctionConcept)
111 __glibcxx_class_requires2(
value_type, _Alloc_value_type, _SameTypeConcept)
117 friend class map<_Key, _Tp, _Compare, _Alloc>;
121 value_compare(_Compare __c)
132 rebind<value_type>::other _Pair_alloc_type;
134 typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
135 key_compare, _Pair_alloc_type> _Rep_type;
145 typedef typename _Alloc_traits::pointer pointer;
146 typedef typename _Alloc_traits::const_pointer const_pointer;
147 typedef typename _Alloc_traits::reference reference;
148 typedef typename _Alloc_traits::const_reference const_reference;
149 typedef typename _Rep_type::iterator iterator;
150 typedef typename _Rep_type::const_iterator const_iterator;
151 typedef typename _Rep_type::size_type size_type;
152 typedef typename _Rep_type::difference_type difference_type;
171 map(
const _Compare& __comp,
173 : _M_t(__comp, _Pair_alloc_type(__a)) { }
185 #if __cplusplus >= 201103L
194 noexcept(is_nothrow_copy_constructible<_Compare>::value)
195 : _M_t(std::move(__x._M_t)) { }
209 const _Compare& __comp = _Compare(),
211 : _M_t(__comp, _Pair_alloc_type(__a))
212 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
217 : _M_t(_Compare(), _Pair_alloc_type(__a)) { }
221 : _M_t(__m._M_t, _Pair_alloc_type(__a)) { }
224 map(
map&& __m,
const allocator_type& __a)
225 noexcept(is_nothrow_copy_constructible<_Compare>::value
227 : _M_t(std::move(__m._M_t), _Pair_alloc_type(__a)) { }
231 : _M_t(_Compare(), _Pair_alloc_type(__a))
232 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
235 template<
typename _InputIterator>
236 map(_InputIterator __first, _InputIterator __last,
238 : _M_t(_Compare(), _Pair_alloc_type(__a))
239 { _M_t._M_insert_unique(__first, __last); }
252 template<
typename _InputIterator>
253 map(_InputIterator __first, _InputIterator __last)
255 { _M_t._M_insert_unique(__first, __last); }
269 template<
typename _InputIterator>
270 map(_InputIterator __first, _InputIterator __last,
271 const _Compare& __comp,
273 : _M_t(__comp, _Pair_alloc_type(__a))
274 { _M_t._M_insert_unique(__first, __last); }
299 #if __cplusplus >= 201103L
310 if (!_M_t._M_move_assign(__x._M_t))
315 insert(std::__make_move_if_noexcept_iterator(__x.begin()),
316 std::__make_move_if_noexcept_iterator(__x.end()));
337 this->
insert(__l.begin(), __l.end());
355 {
return _M_t.begin(); }
364 {
return _M_t.begin(); }
373 {
return _M_t.end(); }
381 end() const _GLIBCXX_NOEXCEPT
382 {
return _M_t.end(); }
391 {
return _M_t.rbegin(); }
398 const_reverse_iterator
400 {
return _M_t.rbegin(); }
409 {
return _M_t.rend(); }
416 const_reverse_iterator
418 {
return _M_t.rend(); }
420 #if __cplusplus >= 201103L
428 {
return _M_t.begin(); }
437 {
return _M_t.end(); }
444 const_reverse_iterator
446 {
return _M_t.rbegin(); }
453 const_reverse_iterator
455 {
return _M_t.rend(); }
464 {
return _M_t.empty(); }
469 {
return _M_t.size(); }
474 {
return _M_t.max_size(); }
493 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
498 #if __cplusplus >= 201103L
505 return (*__i).second;
508 #if __cplusplus >= 201103L
513 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
519 std::forward_as_tuple(std::move(__k)),
521 return (*__i).second;
535 at(
const key_type& __k)
539 __throw_out_of_range(__N(
"map::at"));
540 return (*__i).second;
544 at(
const key_type& __k)
const
548 __throw_out_of_range(__N(
"map::at"));
549 return (*__i).second;
553 #if __cplusplus >= 201103L
572 template<
typename... _Args>
575 {
return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
602 template<
typename... _Args>
606 return _M_t._M_emplace_hint_unique(__pos,
607 std::forward<_Args>(__args)...);
629 {
return _M_t._M_insert_unique(__x); }
631 #if __cplusplus >= 201103L
632 template<
typename _Pair,
typename =
typename
633 std::enable_if<std::is_constructible<value_type,
634 _Pair&&>::value>::type>
637 {
return _M_t._M_insert_unique(std::forward<_Pair>(__x)); }
640 #if __cplusplus >= 201103L
650 {
insert(__list.begin(), __list.end()); }
677 #if __cplusplus >= 201103L
678 insert(const_iterator __position,
const value_type& __x)
682 {
return _M_t._M_insert_unique_(__position, __x); }
684 #if __cplusplus >= 201103L
685 template<
typename _Pair,
typename =
typename
686 std::enable_if<std::is_constructible<value_type,
687 _Pair&&>::value>::type>
689 insert(const_iterator __position, _Pair&& __x)
690 {
return _M_t._M_insert_unique_(__position,
691 std::forward<_Pair>(__x)); }
702 template<
typename _InputIterator>
704 insert(_InputIterator __first, _InputIterator __last)
705 { _M_t._M_insert_unique(__first, __last); }
707 #if __cplusplus >= 201103L
725 {
return _M_t.erase(__position); }
728 _GLIBCXX_ABI_TAG_CXX11
731 {
return _M_t.erase(__position); }
744 erase(iterator __position)
745 { _M_t.erase(__position); }
761 {
return _M_t.erase(__x); }
763 #if __cplusplus >= 201103L
780 erase(const_iterator __first, const_iterator __last)
781 {
return _M_t.erase(__first, __last); }
797 { _M_t.erase(__first, __last); }
813 #if __cplusplus >= 201103L
814 noexcept(_Alloc_traits::_S_nothrow_swap())
816 { _M_t.swap(__x._M_t); }
835 {
return _M_t.key_comp(); }
843 {
return value_compare(_M_t.key_comp()); }
859 {
return _M_t.find(__x); }
873 find(
const key_type& __x)
const
874 {
return _M_t.find(__x); }
886 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
901 {
return _M_t.lower_bound(__x); }
916 {
return _M_t.lower_bound(__x); }
926 {
return _M_t.upper_bound(__x); }
936 {
return _M_t.upper_bound(__x); }
955 {
return _M_t.equal_range(__x); }
974 {
return _M_t.equal_range(__x); }
976 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
981 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
983 operator<(const map<_K1, _T1, _C1, _A1>&,
997 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1001 {
return __x._M_t == __y._M_t; }
1014 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1016 operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1018 {
return __x._M_t < __y._M_t; }
1021 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1025 {
return !(__x == __y); }
1028 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1032 {
return __y < __x; }
1035 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1037 operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1039 {
return !(__y < __x); }
1042 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1046 {
return !(__x < __y); }
1049 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1055 _GLIBCXX_END_NAMESPACE_CONTAINER
Primary class template, tuple.
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
map(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
const_reverse_iterator crend() const noexcept
constexpr piecewise_construct_t piecewise_construct
piecewise_construct
Uniform interface to C++98 and C++0x allocators.
void insert(std::initializer_list< value_type > __list)
Attempts to insert a list of std::pairs into the map.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
map & operator=(map &&__x) noexcept(_Alloc_traits::_S_nothrow_move())
Map move assignment operator.
const_iterator cbegin() const noexcept
map(const map &__x)
Map copy constructor.
iterator find(const key_type &__x)
Tries to locate an element in a map.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the map.
map(_InputIterator __first, _InputIterator __last)
Builds a map from a range.
_T1 first
second_type is the second bound type
Struct holding two objects of arbitrary type.
size_type count(const key_type &__x) const
Finds the number of elements with given key.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
size_type max_size() const noexcept
const_reverse_iterator crbegin() const noexcept
reverse_iterator rbegin() noexcept
map()
Default constructor creates no elements.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
map & operator=(const map &__x)
Map assignment operator.
mapped_type & at(const key_type &__k)
Access to map data.
const_reverse_iterator rbegin() const noexcept
const_reverse_iterator rend() const noexcept
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a map.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
key_compare key_comp() const
map(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
map(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a map from an initializer_list.
map(const map &__m, const allocator_type &__a)
Allocator-extended copy constructor.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
map(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a map from a range.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to map data.
void insert(_InputIterator __first, _InputIterator __last)
Template function that attempts to insert a range of elements.
bool empty() const noexcept
const_iterator end() const noexcept
map(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a map with no elements.
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Attempts to build and insert a std::pair into the map.
iterator begin() noexcept
std::pair< iterator, bool > emplace(_Args &&...__args)
Attempts to build and insert a std::pair into the map.
map & operator=(initializer_list< value_type > __l)
Map list assignment operator.
map(const allocator_type &__a)
Allocator-extended default constructor.
value_compare value_comp() const
The standard allocator, as per [20.4].
void swap(function< _Res(_Args...)> &__x, function< _Res(_Args...)> &__y)
Swap the targets of two polymorphic function object wrappers.
iterator erase(const_iterator __position)
Erases an element from a map.
const_iterator find(const key_type &__x) const
Tries to locate an element in a map.
size_type size() const noexcept
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
noexcept(is_nothrow_copy_constructible< _Compare >::value)
Map move constructor.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
const_iterator begin() const noexcept
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
const_iterator cend() const noexcept
reverse_iterator rend() noexcept