60 #if __cplusplus >= 201103L 64 namespace std _GLIBCXX_VISIBILITY(default)
66 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
68 template<
typename _Key,
typename _Compare,
typename _Alloc>
91 template<
typename _Key,
typename _Compare = std::less<_Key>,
92 typename _Alloc = std::allocator<_Key> >
96 typedef typename _Alloc::value_type _Alloc_value_type;
97 __glibcxx_class_requires(_Key, _SGIAssignableConcept)
98 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
99 _BinaryFunctionConcept)
100 __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
114 typedef typename
__gnu_cxx::__alloc_traits<_Alloc>::template
115 rebind<_Key>::other _Key_alloc_type;
117 typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
118 key_compare, _Key_alloc_type> _Rep_type;
141 #if __cplusplus > 201402L 142 using node_type =
typename _Rep_type::node_type;
143 using insert_return_type =
typename _Rep_type::insert_return_type;
150 #if __cplusplus < 201103L 162 set(
const _Compare& __comp,
164 : _M_t(__comp, _Key_alloc_type(__a)) { }
176 template<
typename _InputIterator>
177 set(_InputIterator __first, _InputIterator __last)
179 { _M_t._M_insert_unique(__first, __last); }
193 template<
typename _InputIterator>
194 set(_InputIterator __first, _InputIterator __last,
195 const _Compare& __comp,
197 : _M_t(__comp, _Key_alloc_type(__a))
198 { _M_t._M_insert_unique(__first, __last); }
210 #if __cplusplus >= 201103L 219 noexcept(is_nothrow_copy_constructible<_Compare>::value)
220 : _M_t(std::move(__x._M_t)) { }
233 const _Compare& __comp = _Compare(),
235 : _M_t(__comp, _Key_alloc_type(__a))
236 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
240 set(
const allocator_type& __a)
241 : _M_t(_Compare(), _Key_alloc_type(__a)) { }
244 set(
const set& __x,
const allocator_type& __a)
245 : _M_t(__x._M_t, _Key_alloc_type(__a)) { }
248 set(
set&& __x,
const allocator_type& __a)
249 noexcept(is_nothrow_copy_constructible<_Compare>::value
250 && _Alloc_traits::_S_always_equal())
251 : _M_t(std::move(__x._M_t), _Key_alloc_type(__a)) { }
255 : _M_t(_Compare(), _Key_alloc_type(__a))
256 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
259 template<
typename _InputIterator>
260 set(_InputIterator __first, _InputIterator __last,
261 const allocator_type& __a)
262 : _M_t(_Compare(), _Key_alloc_type(__a))
263 { _M_t._M_insert_unique(__first, __last); }
281 #if __cplusplus >= 201103L 300 _M_t._M_assign_unique(__l.begin(), __l.end());
310 {
return _M_t.key_comp(); }
314 {
return _M_t.key_comp(); }
327 {
return _M_t.begin(); }
335 end() const _GLIBCXX_NOEXCEPT
336 {
return _M_t.end(); }
345 {
return _M_t.rbegin(); }
354 {
return _M_t.rend(); }
356 #if __cplusplus >= 201103L 364 {
return _M_t.begin(); }
373 {
return _M_t.end(); }
382 {
return _M_t.rbegin(); }
391 {
return _M_t.rend(); }
397 {
return _M_t.empty(); }
402 {
return _M_t.size(); }
407 {
return _M_t.max_size(); }
424 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
425 { _M_t.swap(__x._M_t); }
428 #if __cplusplus >= 201103L 442 template<
typename... _Args>
445 {
return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
468 template<
typename... _Args>
472 return _M_t._M_emplace_hint_unique(__pos,
473 std::forward<_Args>(__args)...);
494 _M_t._M_insert_unique(__x);
498 #if __cplusplus >= 201103L 503 _M_t._M_insert_unique(std::move(__x));
528 insert(const_iterator __position,
const value_type& __x)
529 {
return _M_t._M_insert_unique_(__position, __x); }
531 #if __cplusplus >= 201103L 533 insert(const_iterator __position, value_type&& __x)
534 {
return _M_t._M_insert_unique_(__position, std::move(__x)); }
546 template<
typename _InputIterator>
548 insert(_InputIterator __first, _InputIterator __last)
549 { _M_t._M_insert_unique(__first, __last); }
551 #if __cplusplus >= 201103L 561 { this->
insert(__l.begin(), __l.end()); }
564 #if __cplusplus > 201402L 567 extract(const_iterator __pos)
569 __glibcxx_assert(__pos !=
end());
570 return _M_t.extract(__pos);
575 extract(
const key_type& __x)
576 {
return _M_t.extract(__x); }
581 {
return _M_t._M_reinsert_node_unique(std::move(__nh)); }
585 insert(const_iterator __hint, node_type&& __nh)
586 {
return _M_t._M_reinsert_node_hint_unique(__hint, std::move(__nh)); }
588 template<
typename,
typename>
589 friend class _Rb_tree_merge_helper;
591 template<
typename _Compare1>
595 using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
596 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
599 template<
typename _Compare1>
604 template<
typename _Compare1>
608 using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
609 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
612 template<
typename _Compare1>
618 #if __cplusplus >= 201103L 634 _GLIBCXX_ABI_TAG_CXX11
637 {
return _M_t.erase(__position); }
650 erase(iterator __position)
651 { _M_t.erase(__position); }
667 {
return _M_t.erase(__x); }
669 #if __cplusplus >= 201103L 686 _GLIBCXX_ABI_TAG_CXX11
688 erase(const_iterator __first, const_iterator __last)
689 {
return _M_t.erase(__first, __last); }
704 erase(iterator __first, iterator __last)
705 { _M_t.erase(__first, __last); }
731 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
733 #if __cplusplus > 201103L 734 template<
typename _Kt>
737 -> decltype(_M_t._M_count_tr(__x))
738 {
return _M_t._M_find_tr(__x) == _M_t.end() ? 0 : 1; }
758 {
return _M_t.find(__x); }
761 find(
const key_type& __x)
const 762 {
return _M_t.find(__x); }
764 #if __cplusplus > 201103L 765 template<
typename _Kt>
768 -> decltype(iterator{_M_t._M_find_tr(__x)})
769 {
return iterator{_M_t._M_find_tr(__x)}; }
771 template<
typename _Kt>
774 -> decltype(const_iterator{_M_t._M_find_tr(__x)})
775 {
return const_iterator{_M_t._M_find_tr(__x)}; }
793 {
return _M_t.lower_bound(__x); }
797 {
return _M_t.lower_bound(__x); }
799 #if __cplusplus > 201103L 800 template<
typename _Kt>
803 -> decltype(_M_t._M_lower_bound_tr(__x))
804 {
return _M_t._M_lower_bound_tr(__x); }
806 template<
typename _Kt>
809 -> decltype(_M_t._M_lower_bound_tr(__x))
810 {
return _M_t._M_lower_bound_tr(__x); }
823 {
return _M_t.upper_bound(__x); }
827 {
return _M_t.upper_bound(__x); }
829 #if __cplusplus > 201103L 830 template<
typename _Kt>
833 -> decltype(_M_t._M_upper_bound_tr(__x))
834 {
return _M_t._M_upper_bound_tr(__x); }
836 template<
typename _Kt>
839 -> decltype(_M_t._M_upper_bound_tr(__x))
840 {
return _M_t._M_upper_bound_tr(__x); }
862 {
return _M_t.equal_range(__x); }
866 {
return _M_t.equal_range(__x); }
868 #if __cplusplus > 201103L 869 template<
typename _Kt>
872 -> decltype(_M_t._M_equal_range_tr(__x))
873 {
return _M_t._M_equal_range_tr(__x); }
875 template<
typename _Kt>
878 -> decltype(_M_t._M_equal_range_tr(__x))
879 {
return _M_t._M_equal_range_tr(__x); }
883 template<
typename _K1,
typename _C1,
typename _A1>
887 template<
typename _K1,
typename _C1,
typename _A1>
903 template<
typename _Key,
typename _Compare,
typename _Alloc>
907 {
return __x._M_t == __y._M_t; }
920 template<
typename _Key,
typename _Compare,
typename _Alloc>
922 operator<(const set<_Key, _Compare, _Alloc>& __x,
924 {
return __x._M_t < __y._M_t; }
927 template<
typename _Key,
typename _Compare,
typename _Alloc>
931 {
return !(__x == __y); }
934 template<
typename _Key,
typename _Compare,
typename _Alloc>
938 {
return __y < __x; }
941 template<
typename _Key,
typename _Compare,
typename _Alloc>
943 operator<=(const set<_Key, _Compare, _Alloc>& __x,
945 {
return !(__y < __x); }
948 template<
typename _Key,
typename _Compare,
typename _Alloc>
952 {
return !(__x < __y); }
955 template<
typename _Key,
typename _Compare,
typename _Alloc>
958 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
961 _GLIBCXX_END_NAMESPACE_CONTAINER
963 #if __cplusplus > 201402L 964 _GLIBCXX_BEGIN_NAMESPACE_VERSION
966 template<
typename _Val,
typename _Cmp1,
typename _Alloc,
typename _Cmp2>
968 _Rb_tree_merge_helper<_GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>, _Cmp2>
971 friend class _GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>;
974 _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set)
975 {
return __set._M_t; }
978 _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set)
979 {
return __set._M_t; }
981 _GLIBCXX_END_NAMESPACE_VERSION
std::pair< iterator, bool > emplace(_Args &&... __args)
Attempts to build and insert an element into the set.
value_compare value_comp() const
Returns the comparison object with which the set was constructed.
A standard container made up of unique keys, which can be retrieved in logarithmic time...
_Alloc allocator_type
Public typedefs.
_Rep_type::const_iterator const_iterator
Iterator-related typedefs.
auto lower_bound(const _Kt &__x) const -> decltype(_M_t._M_lower_bound_tr(__x))
Finds the beginning of a subsequence matching given key.
_T2 second
first is a copy of the first object
bool operator>(const set< _Key, _Compare, _Alloc > &__x, const set< _Key, _Compare, _Alloc > &__y)
Returns y < x.
reverse_iterator rbegin() const noexcept
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __position)
Erases an element from a set.
auto upper_bound(const _Kt &__x) const -> decltype(_M_t._M_upper_bound_tr(__x))
Finds the end of a subsequence matching given key.
auto equal_range(const _Kt &__x) -> decltype(_M_t._M_equal_range_tr(__x))
Finds a subsequence matching given key.
_Alloc_traits::const_reference const_reference
Iterator-related typedefs.
auto find(const _Kt &__x) const -> decltype(const_iterator
Tries to locate an element in a set.
Uniform interface to C++98 and C++11 allocators.
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert an element into the set.
_Key value_type
Public typedefs.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
_Alloc_traits::reference reference
Iterator-related typedefs.
ISO C++ entities toplevel namespace is std.
const_iterator find(const key_type &__x) const
Tries to locate an element in a set.
auto find(const _Kt &__x) -> decltype(iterator
Tries to locate an element in a set.
iterator end() const noexcept
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from a set.
void swap(set &__x) noexcept(/*conditional */)
Swaps data with another set.
auto equal_range(const _Kt &__x) const -> decltype(_M_t._M_equal_range_tr(__x))
Finds a subsequence matching given key.
size_type count(const key_type &__x) const
Finds the number of elements.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
GNU extensions for public use.
bool operator==(const set< _Key, _Compare, _Alloc > &__x, const set< _Key, _Compare, _Alloc > &__y)
Set equality comparison.
key_compare key_comp() const
Returns the comparison object with which the set was constructed.
auto upper_bound(const _Kt &__x) -> decltype(_M_t._M_upper_bound_tr(__x))
Finds the end of a subsequence matching given key.
_Rep_type::size_type size_type
Iterator-related typedefs.
iterator cbegin() const noexcept
set & operator=(initializer_list< value_type > __l)
Set list assignment operator.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
iterator begin() const noexcept
_Compare key_compare
Public typedefs.
reverse_iterator rend() const noexcept
allocator_type get_allocator() const noexcept
Returns the allocator object with which the set was constructed.
bool operator!=(const set< _Key, _Compare, _Alloc > &__x, const set< _Key, _Compare, _Alloc > &__y)
Returns !(x == y).
Struct holding two objects of arbitrary type.
size_type size() const noexcept
Returns the size of the set.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
iterator find(const key_type &__x)
Tries to locate an element in a set.
_Alloc_traits::pointer pointer
Iterator-related typedefs.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
A standard container made up of elements, which can be retrieved in logarithmic time.
reverse_iterator crbegin() const noexcept
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
iterator cend() const noexcept
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Attempts to insert an element into the set.
_Rep_type::difference_type difference_type
Iterator-related typedefs.
_Alloc_traits::const_pointer const_pointer
Iterator-related typedefs.
auto lower_bound(const _Kt &__x) -> decltype(_M_t._M_lower_bound_tr(__x))
Finds the beginning of a subsequence matching given key.
iterator insert(const_iterator __position, const value_type &__x)
Attempts to insert an element into the set.
size_type max_size() const noexcept
Returns the maximum size of the set.
_Rep_type::const_iterator iterator
Iterator-related typedefs.
_Compare value_compare
Public typedefs.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
bool empty() const noexcept
Returns true if the set is empty.
set & operator=(const set &__x)
Set assignment operator.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the set.
reverse_iterator crend() const noexcept
bool operator>=(const set< _Key, _Compare, _Alloc > &__x, const set< _Key, _Compare, _Alloc > &__y)
Returns !(x < y)
_Key key_type
Public typedefs.
_T1 first
second_type is the second bound type