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
131 typedef typename _Alloc::template rebind<value_type>::other
134 typedef _Rb_tree<key_type, value_type, _Select1st<value_type>,
135 key_compare, _Pair_alloc_type> _Rep_type;
143 typedef typename _Pair_alloc_type::pointer pointer;
144 typedef typename _Pair_alloc_type::const_pointer const_pointer;
145 typedef typename _Pair_alloc_type::reference reference;
146 typedef typename _Pair_alloc_type::const_reference const_reference;
147 typedef typename _Rep_type::iterator iterator;
148 typedef typename _Rep_type::const_iterator const_iterator;
149 typedef typename _Rep_type::size_type size_type;
150 typedef typename _Rep_type::difference_type difference_type;
169 map(
const _Compare& __comp,
170 const allocator_type& __a = allocator_type())
171 : _M_t(__comp, _Pair_alloc_type(__a)) { }
183 #if __cplusplus >= 201103L
192 noexcept(is_nothrow_copy_constructible<_Compare>::value)
193 : _M_t(
std::
move(__x._M_t)) { }
206 map(initializer_list<value_type> __l,
207 const _Compare& __comp = _Compare(),
208 const allocator_type& __a = allocator_type())
209 : _M_t(__comp, _Pair_alloc_type(__a))
210 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
223 template<
typename _InputIterator>
224 map(_InputIterator __first, _InputIterator __last)
226 { _M_t._M_insert_unique(__first, __last); }
240 template<
typename _InputIterator>
241 map(_InputIterator __first, _InputIterator __last,
242 const _Compare& __comp,
243 const allocator_type& __a = allocator_type())
244 : _M_t(__comp, _Pair_alloc_type(__a))
245 { _M_t._M_insert_unique(__first, __last); }
270 #if __cplusplus >= 201103L
303 this->
insert(__l.begin(), __l.end());
311 {
return allocator_type(_M_t.get_allocator()); }
321 {
return _M_t.begin(); }
330 {
return _M_t.begin(); }
339 {
return _M_t.end(); }
347 end() const _GLIBCXX_NOEXCEPT
348 {
return _M_t.end(); }
357 {
return _M_t.rbegin(); }
364 const_reverse_iterator
366 {
return _M_t.rbegin(); }
375 {
return _M_t.rend(); }
382 const_reverse_iterator
384 {
return _M_t.rend(); }
386 #if __cplusplus >= 201103L
394 {
return _M_t.begin(); }
403 {
return _M_t.end(); }
410 const_reverse_iterator
412 {
return _M_t.rbegin(); }
419 const_reverse_iterator
421 {
return _M_t.rend(); }
430 {
return _M_t.empty(); }
435 {
return _M_t.size(); }
440 {
return _M_t.max_size(); }
459 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
464 #if __cplusplus >= 201103L
466 std::tuple<const key_type&>(__k),
469 __i =
insert(__i, value_type(__k, mapped_type()));
471 return (*__i).second;
474 #if __cplusplus >= 201103L
479 __glibcxx_function_requires(_DefaultConstructibleConcept<mapped_type>)
487 return (*__i).second;
501 at(
const key_type& __k)
505 __throw_out_of_range(__N(
"map::at"));
506 return (*__i).second;
510 at(
const key_type& __k)
const
514 __throw_out_of_range(__N(
"map::at"));
515 return (*__i).second;
519 #if __cplusplus >= 201103L
538 template<
typename... _Args>
541 {
return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
568 template<
typename... _Args>
572 return _M_t._M_emplace_hint_unique(__pos,
573 std::forward<_Args>(__args)...);
595 {
return _M_t._M_insert_unique(__x); }
597 #if __cplusplus >= 201103L
598 template<
typename _Pair,
typename =
typename
599 std::enable_if<std::is_constructible<value_type,
600 _Pair&&>::value>::type>
603 {
return _M_t._M_insert_unique(std::forward<_Pair>(__x)); }
606 #if __cplusplus >= 201103L
615 insert(std::initializer_list<value_type> __list)
616 {
insert(__list.begin(), __list.end()); }
643 #if __cplusplus >= 201103L
644 insert(const_iterator __position,
const value_type& __x)
646 insert(iterator __position,
const value_type& __x)
648 {
return _M_t._M_insert_unique_(__position, __x); }
650 #if __cplusplus >= 201103L
651 template<
typename _Pair,
typename =
typename
652 std::enable_if<std::is_constructible<value_type,
653 _Pair&&>::value>::type>
655 insert(const_iterator __position, _Pair&& __x)
656 {
return _M_t._M_insert_unique_(__position,
657 std::forward<_Pair>(__x)); }
668 template<
typename _InputIterator>
670 insert(_InputIterator __first, _InputIterator __last)
671 { _M_t._M_insert_unique(__first, __last); }
673 #if __cplusplus >= 201103L
691 {
return _M_t.erase(__position); }
694 _GLIBCXX_ABI_TAG_CXX11
696 erase(iterator __position)
697 {
return _M_t.erase(__position); }
710 erase(iterator __position)
711 { _M_t.erase(__position); }
727 {
return _M_t.erase(__x); }
729 #if __cplusplus >= 201103L
746 erase(const_iterator __first, const_iterator __last)
747 {
return _M_t.erase(__first, __last); }
762 erase(iterator __first, iterator __last)
763 { _M_t.erase(__first, __last); }
779 { _M_t.swap(__x._M_t); }
798 {
return _M_t.key_comp(); }
806 {
return value_compare(_M_t.key_comp()); }
822 {
return _M_t.find(__x); }
836 find(
const key_type& __x)
const
837 {
return _M_t.find(__x); }
849 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
864 {
return _M_t.lower_bound(__x); }
879 {
return _M_t.lower_bound(__x); }
889 {
return _M_t.upper_bound(__x); }
899 {
return _M_t.upper_bound(__x); }
918 {
return _M_t.equal_range(__x); }
937 {
return _M_t.equal_range(__x); }
939 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
944 template<
typename _K1,
typename _T1,
typename _C1,
typename _A1>
946 operator<(const map<_K1, _T1, _C1, _A1>&,
960 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
964 {
return __x._M_t == __y._M_t; }
977 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
979 operator<(const map<_Key, _Tp, _Compare, _Alloc>& __x,
981 {
return __x._M_t < __y._M_t; }
984 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
988 {
return !(__x == __y); }
991 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
995 {
return __y < __x; }
998 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1000 operator<=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
1002 {
return !(__y < __x); }
1005 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1009 {
return !(__x < __y); }
1012 template<
typename _Key,
typename _Tp,
typename _Compare,
typename _Alloc>
1018 _GLIBCXX_END_NAMESPACE_CONTAINER
std::pair< iterator, bool > emplace(_Args &&...__args)
Attempts to build and insert a std::pair into the map.
mapped_type & at(const key_type &__k)
Access to map data.
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.
reverse_iterator rbegin() noexcept
reverse_iterator rend() noexcept
constexpr piecewise_construct_t piecewise_construct
piecewise_construct
map(const map &__x)
Map copy constructor.
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
map(_InputIterator __first, _InputIterator __last)
Builds a map from a range.
map & operator=(initializer_list< value_type > __l)
Map list assignment operator.
const_reverse_iterator crbegin() const noexcept
map(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a map from a range.
map()
Default constructor creates no elements.
const_iterator cbegin() const noexcept
map(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a map from an initializer_list.
const_iterator cend() const noexcept
void swap(map &__x)
Swaps data with another map.
map & operator=(map &&__x)
Map move assignment operator.
const_reverse_iterator crend() const noexcept
bool operator==(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Map equality comparison.
void insert(_InputIterator __first, _InputIterator __last)
Template function that attempts to insert a range of elements.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
iterator erase(const_iterator __first, const_iterator __last)
Erases a [first,last) range of elements from a map.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
iterator insert(const_iterator __position, const value_type &__x)
Attempts to insert a std::pair into the map.
bool empty() const noexcept
iterator begin() noexcept
map(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a map with no elements.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
mapped_type & operator[](const key_type &__k)
Subscript ( [] ) access to map data.
ISO C++ entities toplevel namespace is std.
size_type size() const noexcept
_T1 first
second_type is the second bound type
const_iterator end() const noexcept
value_compare value_comp() const
iterator find(const key_type &__x)
Tries to locate an element in a map.
bool operator!=(const map< _Key, _Tp, _Compare, _Alloc > &__x, const map< _Key, _Tp, _Compare, _Alloc > &__y)
Based on operator==.
A standard container made up of (key,value) pairs, which can be retrieved based on a key...
map(map &&__x) noexcept(is_nothrow_copy_constructible< _Compare >::value)
Map move constructor.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
const_reverse_iterator rbegin() const noexcept
size_type max_size() const noexcept
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
const_reverse_iterator rend() const noexcept
const_iterator begin() const noexcept
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
size_type count(const key_type &__x) const
Finds the number of elements with given key.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert a std::pair into the map.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
Struct holding two objects of arbitrary type.
key_compare key_comp() const
iterator erase(const_iterator __position)
Erases an element from a map.
map & operator=(const map &__x)
Map assignment operator.
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.
iterator emplace_hint(const_iterator __pos, _Args &&...__args)
Attempts to build and insert a std::pair into the map.