61 #if __cplusplus >= 201103L
62 #include <initializer_list>
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)
125 bool operator()(
const value_type& __x,
const value_type& __y)
const
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,
172 const allocator_type& __a = allocator_type())
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)) { }
208 map(initializer_list<value_type> __l,
209 const _Compare& __comp = _Compare(),
210 const allocator_type& __a = allocator_type())
211 : _M_t(__comp, _Pair_alloc_type(__a))
212 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
216 map(
const allocator_type& __a)
217 : _M_t(_Compare(), _Pair_alloc_type(__a)) { }
220 map(
const map& __m,
const allocator_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
226 && _Alloc_traits::_S_always_equal())
227 : _M_t(
std::
move(__m._M_t), _Pair_alloc_type(__a)) { }
230 map(initializer_list<value_type> __l,
const allocator_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,
237 const allocator_type& __a)
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,
272 const allocator_type& __a = allocator_type())
273 : _M_t(__comp, _Pair_alloc_type(__a))
274 { _M_t._M_insert_unique(__first, __last); }
299 #if __cplusplus >= 201103L
311 if (!_M_t._M_move_assign(__x._M_t))
316 insert(std::__make_move_if_noexcept_iterator(__x.begin()),
317 std::__make_move_if_noexcept_iterator(__x.end()));
338 this->
insert(__l.begin(), __l.end());
346 {
return allocator_type(_M_t.get_allocator()); }
356 {
return _M_t.begin(); }
365 {
return _M_t.begin(); }
374 {
return _M_t.end(); }
382 end() const _GLIBCXX_NOEXCEPT
383 {
return _M_t.end(); }
392 {
return _M_t.rbegin(); }
399 const_reverse_iterator
401 {
return _M_t.rbegin(); }
410 {
return _M_t.rend(); }
417 const_reverse_iterator
419 {
return _M_t.rend(); }
421 #if __cplusplus >= 201103L
429 {
return _M_t.begin(); }
438 {
return _M_t.end(); }
445 const_reverse_iterator
447 {
return _M_t.rbegin(); }
454 const_reverse_iterator
456 {
return _M_t.rend(); }
465 {
return _M_t.empty(); }
470 {
return _M_t.size(); }
475 {
return _M_t.max_size(); }
494 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
499 #if __cplusplus >= 201103L
501 std::tuple<const key_type&>(__k),
504 __i =
insert(__i, value_type(__k, mapped_type()));
506 return (*__i).second;
509 #if __cplusplus >= 201103L
514 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
522 return (*__i).second;
536 at(
const key_type& __k)
540 __throw_out_of_range(__N(
"map::at"));
541 return (*__i).second;
545 at(
const key_type& __k)
const
549 __throw_out_of_range(__N(
"map::at"));
550 return (*__i).second;
554 #if __cplusplus >= 201103L
573 template<
typename... _Args>
576 {
return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
603 template<
typename... _Args>
607 return _M_t._M_emplace_hint_unique(__pos,
608 std::forward<_Args>(__args)...);
630 {
return _M_t._M_insert_unique(__x); }
632 #if __cplusplus >= 201103L
633 template<
typename _Pair,
typename =
typename
634 std::enable_if<std::is_constructible<value_type,
635 _Pair&&>::value>::type>
638 {
return _M_t._M_insert_unique(std::forward<_Pair>(__x)); }
641 #if __cplusplus >= 201103L
650 insert(std::initializer_list<value_type> __list)
651 {
insert(__list.begin(), __list.end()); }
678 #if __cplusplus >= 201103L
679 insert(const_iterator __position,
const value_type& __x)
681 insert(iterator __position,
const value_type& __x)
683 {
return _M_t._M_insert_unique_(__position, __x); }
685 #if __cplusplus >= 201103L
686 template<
typename _Pair,
typename =
typename
687 std::enable_if<std::is_constructible<value_type,
688 _Pair&&>::value>::type>
690 insert(const_iterator __position, _Pair&& __x)
691 {
return _M_t._M_insert_unique_(__position,
692 std::forward<_Pair>(__x)); }
703 template<
typename _InputIterator>
705 insert(_InputIterator __first, _InputIterator __last)
706 { _M_t._M_insert_unique(__first, __last); }
708 #if __cplusplus >= 201103L
726 {
return _M_t.erase(__position); }
729 _GLIBCXX_ABI_TAG_CXX11
731 erase(iterator __position)
732 {
return _M_t.erase(__position); }
745 erase(iterator __position)
746 { _M_t.erase(__position); }
762 {
return _M_t.erase(__x); }
764 #if __cplusplus >= 201103L
781 erase(const_iterator __first, const_iterator __last)
782 {
return _M_t.erase(__first, __last); }
797 erase(iterator __first, iterator __last)
798 { _M_t.erase(__first, __last); }
814 #if __cplusplus >= 201103L
815 noexcept(_Alloc_traits::_S_nothrow_swap())
817 { _M_t.swap(__x._M_t); }
836 {
return _M_t.key_comp(); }
844 {
return value_compare(_M_t.key_comp()); }
860 {
return _M_t.find(__x); }
874 find(
const key_type& __x)
const
875 {
return _M_t.find(__x); }
887 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
902 {
return _M_t.lower_bound(__x); }
917 {
return _M_t.lower_bound(__x); }
927 {
return _M_t.upper_bound(__x); }
937 {
return _M_t.upper_bound(__x); }
956 {
return _M_t.equal_range(__x); }
975 {
return _M_t.equal_range(__x); }
977 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
982 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
984 operator<(const map<_K1, _T1, _C1, _A1>&,
998 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1002 {
return __x._M_t == __y._M_t; }
1015 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1017 operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1019 {
return __x._M_t < __y._M_t; }
1022 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1026 {
return !(__x == __y); }
1029 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1033 {
return __y < __x; }
1036 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1038 operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1040 {
return !(__y < __x); }
1043 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1047 {
return !(__x < __y); }
1050 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1056 _GLIBCXX_END_NAMESPACE_CONTAINER
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
map(_InputIterator __first, _InputIterator __last, const allocator_type &__a)
Allocator-extended range constructor.
map & operator=(map &&__x) noexcept(_Alloc_traits::_S_nothrow_move())
Map move assignment operator.
map(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a map from an initializer_list.
std::pair< iterator, bool > emplace(_Args &&...__args)
Attempts to build and insert a std::pair into the map.
const_iterator cend() const noexcept
const_reverse_iterator crend() const noexcept
Uniform interface to C++98 and C++0x allocators.
map(const allocator_type &__a)
Allocator-extended default constructor.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
bool operator==(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Map equality comparison.
constexpr piecewise_construct_t piecewise_construct
piecewise_construct
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
map(map &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Map move constructor.
iterator insert(const_iterator __position, const value_type &__x)
Attempts to insert a std::pair into the map.
map(const map &__m, const allocator_type &__a)
Allocator-extended copy constructor.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
bool empty() const noexcept
void swap(map &__x) noexcept(_Alloc_traits::_S_nothrow_swap())
Swaps data with another map.
void insert(_InputIterator __first, _InputIterator __last)
Template function that attempts to insert a range of elements.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
map(map &&__m, const allocator_type &__a) noexcept(is_nothrow_copy_constructible< _Compare >::value &&_Alloc_traits::_S_always_equal())
Allocator-extended move constructor.
bool operator!=(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator==.
_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...
ISO C++ entities toplevel namespace is std.
value_compare value_comp() const
map(initializer_list< value_type > __l, const allocator_type &__a)
Allocator-extended initialier-list constructor.
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Attempts to build and insert a std::pair into the map.
map(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a map with no elements.
map(const map &__x)
Map copy constructor.
mapped_type & at(const key_type &__k)
Access to map data.
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to map data.
reverse_iterator rend() noexcept
const_iterator end() const noexcept
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the map.
const_reverse_iterator rbegin() const noexcept
map(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a map from a range.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
iterator find(const key_type &__x)
Tries to locate an element in a map.
map & operator=(const map &__x)
Map assignment operator.
reverse_iterator rbegin() noexcept
map & operator=(initializer_list< value_type > __l)
Map list assignment operator.
map(_InputIterator __first, _InputIterator __last)
Builds a map from a range.
const_reverse_iterator crbegin() const noexcept
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.
iterator erase(const_iterator __position)
Erases an element from a map.
const_iterator cbegin() const noexcept
const_reverse_iterator rend() const noexcept
size_type max_size() const noexcept
size_type size() const noexcept
Struct holding two objects of arbitrary type.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a map.
const_iterator find(const key_type &__x) const
Tries to locate an element in a map.
void insert(std::initializer_list< value_type > __list)
Attempts to insert a list of std::pairs into the map.
const_iterator begin() const noexcept
key_compare key_comp() const
iterator begin() noexcept
map()
Default constructor creates no elements.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
size_type count(const key_type &__x) const
Finds the number of elements with given key.