60 #if __cplusplus >= 201103L 64 namespace std _GLIBCXX_VISIBILITY(default)
66 _GLIBCXX_BEGIN_NAMESPACE_VERSION
67 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
69 template<
typename _Key,
typename _Compare,
typename _Alloc>
92 template<
typename _Key,
typename _Compare = std::less<_Key>,
93 typename _Alloc = std::allocator<_Key> >
96 #ifdef _GLIBCXX_CONCEPT_CHECKS 98 typedef typename _Alloc::value_type _Alloc_value_type;
99 # if __cplusplus < 201103L 100 __glibcxx_class_requires(_Key, _SGIAssignableConcept)
102 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
103 _BinaryFunctionConcept)
104 __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
107 #if __cplusplus >= 201103L 108 static_assert(is_same<
typename remove_cv<_Key>::type, _Key>::value,
109 "std::set must have a non-const, non-volatile value_type");
110 # ifdef __STRICT_ANSI__ 112 "std::set must have the same value_type as its allocator");
129 rebind<_Key>::other _Key_alloc_type;
131 typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
140 typedef typename _Alloc_traits::pointer
pointer;
147 typedef typename _Rep_type::const_iterator
iterator;
155 #if __cplusplus > 201402L 156 using node_type =
typename _Rep_type::node_type;
157 using insert_return_type =
typename _Rep_type::insert_return_type;
164 #if __cplusplus < 201103L 176 set(
const _Compare& __comp,
178 : _M_t(__comp, _Key_alloc_type(__a)) { }
190 template<
typename _InputIterator>
191 set(_InputIterator __first, _InputIterator __last)
193 { _M_t._M_insert_range_unique(__first, __last); }
207 template<
typename _InputIterator>
208 set(_InputIterator __first, _InputIterator __last,
209 const _Compare& __comp,
211 : _M_t(__comp, _Key_alloc_type(__a))
212 { _M_t._M_insert_range_unique(__first, __last); }
219 #if __cplusplus < 201103L 223 set(
const set&) =
default;
231 set(
set&&) =
default;
244 const _Compare& __comp = _Compare(),
246 : _M_t(__comp, _Key_alloc_type(__a))
247 { _M_t._M_insert_range_unique(__l.begin(), __l.end()); }
252 : _M_t(_Key_alloc_type(__a)) { }
256 : _M_t(__x._M_t, _Key_alloc_type(__a)) { }
261 && _Alloc_traits::_S_always_equal())
262 : _M_t(std::move(__x._M_t), _Key_alloc_type(__a)) { }
266 : _M_t(_Key_alloc_type(__a))
267 { _M_t._M_insert_range_unique(__l.begin(), __l.end()); }
270 template<
typename _InputIterator>
271 set(_InputIterator __first, _InputIterator __last,
273 : _M_t(_Key_alloc_type(__a))
274 { _M_t._M_insert_range_unique(__first, __last); }
289 #if __cplusplus < 201103L 318 _M_t._M_assign_unique(__l.begin(), __l.end());
328 {
return _M_t.key_comp(); }
332 {
return _M_t.key_comp(); }
345 {
return _M_t.begin(); }
353 end() const _GLIBCXX_NOEXCEPT
354 {
return _M_t.end(); }
363 {
return _M_t.rbegin(); }
372 {
return _M_t.rend(); }
374 #if __cplusplus >= 201103L 382 {
return _M_t.begin(); }
391 {
return _M_t.end(); }
400 {
return _M_t.rbegin(); }
409 {
return _M_t.rend(); }
413 _GLIBCXX_NODISCARD
bool 415 {
return _M_t.empty(); }
420 {
return _M_t.size(); }
425 {
return _M_t.max_size(); }
442 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
443 { _M_t.swap(__x._M_t); }
446 #if __cplusplus >= 201103L 460 template<
typename... _Args>
463 {
return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
486 template<
typename... _Args>
490 return _M_t._M_emplace_hint_unique(__pos,
491 std::forward<_Args>(__args)...);
512 _M_t._M_insert_unique(__x);
516 #if __cplusplus >= 201103L 521 _M_t._M_insert_unique(std::move(__x));
547 {
return _M_t._M_insert_unique_(__position, __x); }
549 #if __cplusplus >= 201103L 552 {
return _M_t._M_insert_unique_(__position, std::move(__x)); }
564 template<
typename _InputIterator>
566 insert(_InputIterator __first, _InputIterator __last)
567 { _M_t._M_insert_range_unique(__first, __last); }
569 #if __cplusplus >= 201103L 579 { this->
insert(__l.begin(), __l.end()); }
582 #if __cplusplus > 201402L 587 __glibcxx_assert(__pos !=
end());
588 return _M_t.extract(__pos);
594 {
return _M_t.extract(__x); }
599 {
return _M_t._M_reinsert_node_unique(std::move(__nh)); }
604 {
return _M_t._M_reinsert_node_hint_unique(__hint, std::move(__nh)); }
606 template<
typename,
typename>
607 friend class std::_Rb_tree_merge_helper;
609 template<
typename _Compare1>
611 merge(set<_Key, _Compare1, _Alloc>& __source)
613 using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
614 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
617 template<
typename _Compare1>
619 merge(set<_Key, _Compare1, _Alloc>&& __source)
622 template<
typename _Compare1>
624 merge(multiset<_Key, _Compare1, _Alloc>& __source)
626 using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
627 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
630 template<
typename _Compare1>
632 merge(multiset<_Key, _Compare1, _Alloc>&& __source)
636 #if __cplusplus >= 201103L 652 _GLIBCXX_ABI_TAG_CXX11
655 {
return _M_t.erase(__position); }
669 { _M_t.erase(__position); }
685 {
return _M_t.erase(__x); }
687 #if __cplusplus >= 201103L 704 _GLIBCXX_ABI_TAG_CXX11
707 {
return _M_t.erase(__first, __last); }
723 { _M_t.erase(__first, __last); }
749 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
751 #if __cplusplus > 201103L 752 template<
typename _Kt>
755 -> decltype(_M_t._M_count_tr(__x))
756 {
return _M_t._M_count_tr(__x); }
760 #if __cplusplus > 201703L 769 {
return _M_t.find(__x) != _M_t.end(); }
771 template<
typename _Kt>
773 contains(
const _Kt& __x)
const 774 -> decltype(_M_t._M_find_tr(__x), void(),
true)
775 {
return _M_t._M_find_tr(__x) != _M_t.end(); }
795 {
return _M_t.find(__x); }
799 {
return _M_t.find(__x); }
801 #if __cplusplus > 201103L 802 template<
typename _Kt>
805 -> decltype(
iterator{_M_t._M_find_tr(__x)})
806 {
return iterator{_M_t._M_find_tr(__x)}; }
808 template<
typename _Kt>
830 {
return _M_t.lower_bound(__x); }
834 {
return _M_t.lower_bound(__x); }
836 #if __cplusplus > 201103L 837 template<
typename _Kt>
840 -> decltype(
iterator(_M_t._M_lower_bound_tr(__x)))
841 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
843 template<
typename _Kt>
860 {
return _M_t.upper_bound(__x); }
864 {
return _M_t.upper_bound(__x); }
866 #if __cplusplus > 201103L 867 template<
typename _Kt>
870 -> decltype(
iterator(_M_t._M_upper_bound_tr(__x)))
871 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
873 template<
typename _Kt>
876 -> decltype(
iterator(_M_t._M_upper_bound_tr(__x)))
899 {
return _M_t.equal_range(__x); }
903 {
return _M_t.equal_range(__x); }
905 #if __cplusplus > 201103L 906 template<
typename _Kt>
912 template<
typename _Kt>
920 template<
typename _K1,
typename _C1,
typename _A1>
924 template<
typename _K1,
typename _C1,
typename _A1>
929 #if __cpp_deduction_guides >= 201606 931 template<
typename _InputIterator,
933 less<typename iterator_traits<_InputIterator>::value_type>,
934 typename _Allocator =
935 allocator<typename iterator_traits<_InputIterator>::value_type>,
936 typename = _RequireInputIter<_InputIterator>,
937 typename = _RequireNotAllocator<_Compare>,
938 typename = _RequireAllocator<_Allocator>>
939 set(_InputIterator, _InputIterator,
940 _Compare = _Compare(), _Allocator = _Allocator())
941 ->
set<
typename iterator_traits<_InputIterator>::value_type,
942 _Compare, _Allocator>;
944 template<
typename _Key,
typename _Compare = less<_Key>,
945 typename _Allocator = allocator<_Key>,
946 typename = _RequireNotAllocator<_Compare>,
947 typename = _RequireAllocator<_Allocator>>
948 set(initializer_list<_Key>,
949 _Compare = _Compare(), _Allocator = _Allocator())
950 -> set<_Key, _Compare, _Allocator>;
952 template<
typename _InputIterator,
typename _Allocator,
953 typename = _RequireInputIter<_InputIterator>,
954 typename = _RequireAllocator<_Allocator>>
955 set(_InputIterator, _InputIterator, _Allocator)
956 ->
set<
typename iterator_traits<_InputIterator>::value_type,
957 less<
typename iterator_traits<_InputIterator>::value_type>,
960 template<
typename _Key,
typename _Allocator,
961 typename = _RequireAllocator<_Allocator>>
962 set(initializer_list<_Key>, _Allocator)
963 ->
set<_Key, less<_Key>, _Allocator>;
977 template<
typename _Key,
typename _Compare,
typename _Alloc>
981 {
return __x._M_t == __y._M_t; }
994 template<
typename _Key,
typename _Compare,
typename _Alloc>
996 operator<(const set<_Key, _Compare, _Alloc>& __x,
998 {
return __x._M_t < __y._M_t; }
1001 template<
typename _Key,
typename _Compare,
typename _Alloc>
1005 {
return !(__x == __y); }
1008 template<
typename _Key,
typename _Compare,
typename _Alloc>
1012 {
return __y < __x; }
1015 template<
typename _Key,
typename _Compare,
typename _Alloc>
1017 operator<=(const set<_Key, _Compare, _Alloc>& __x,
1019 {
return !(__y < __x); }
1022 template<
typename _Key,
typename _Compare,
typename _Alloc>
1026 {
return !(__x < __y); }
1029 template<
typename _Key,
typename _Compare,
typename _Alloc>
1032 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
1035 _GLIBCXX_END_NAMESPACE_CONTAINER
1037 #if __cplusplus > 201402L 1039 template<
typename _Val,
typename _Cmp1,
typename _Alloc,
typename _Cmp2>
1041 _Rb_tree_merge_helper<_GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>, _Cmp2>
1044 friend class _GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>;
1047 _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set)
1048 {
return __set._M_t; }
1051 _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set)
1052 {
return __set._M_t; }
1056 _GLIBCXX_END_NAMESPACE_VERSION
reverse_iterator rbegin() const noexcept
_T2 second
first is a copy of the first object
auto equal_range(const _Kt &__x) -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
_Alloc_traits::const_reference const_reference
Iterator-related typedefs.
set & operator=(const set &)=default
Set assignment operator.
_Alloc_traits::const_pointer const_pointer
Iterator-related typedefs.
iterator cbegin() const noexcept
ISO C++ entities toplevel namespace is std.
reverse_iterator rend() const noexcept
value_compare value_comp() const
Returns the comparison object with which the set was constructed.
_Alloc_traits::pointer pointer
Iterator-related typedefs.
iterator end() const noexcept
key_compare key_comp() const
Returns the comparison object with which the set was constructed.
_Rep_type::difference_type difference_type
Iterator-related typedefs.
reverse_iterator crend() const noexcept
const_iterator find(const key_type &__x) const
Tries to locate an element in a set.
A standard container made up of unique keys, which can be retrieved in logarithmic time...
size_type max_size() const noexcept
Returns the maximum size of the set.
_Compare key_compare
Public typedefs.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
_Key key_type
Public typedefs.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the set.
_Alloc allocator_type
Public typedefs.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert an element into the set.
_T1 first
second_type is the second bound type
_Rep_type::const_reverse_iterator const_reverse_iterator
Iterator-related typedefs.
_Alloc_traits::reference reference
Iterator-related typedefs.
size_type size() const noexcept
Returns the size of the set.
_Rep_type::const_iterator iterator
Iterator-related typedefs.
_GLIBCXX_NODISCARD bool empty() const noexcept
Returns true if the set is empty.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
_Rep_type::const_iterator const_iterator
Iterator-related typedefs.
iterator cend() const noexcept
set & operator=(initializer_list< value_type > __l)
Set list assignment operator.
is_nothrow_copy_constructible
iterator insert(const_iterator __position, const value_type &__x)
Attempts to insert an element into the set.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements.
size_type count(const key_type &__x) const
Finds the number of elements.
iterator find(const key_type &__x)
Tries to locate an element in a set.
void swap(set &__x) noexcept(/*conditional */)
Swaps data with another set.
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
Uniform interface to C++98 and C++11 allocators.
auto find(const _Kt &__x) -> decltype(iterator
Tries to locate an element in a set.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __position)
Erases an element from a set.
_Key value_type
Public typedefs.
auto lower_bound(const _Kt &__x) const -> decltype(const_iterator(_M_t._M_lower_bound_tr(__x)))
Finds the beginning of a subsequence matching given key.
reverse_iterator crbegin() const noexcept
iterator begin() const noexcept
_Compare value_compare
Public typedefs.
auto lower_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
Finds the beginning of a subsequence matching given key.
_Rep_type::size_type size_type
Iterator-related typedefs.
void insert(_InputIterator __first, _InputIterator __last)
A 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.
auto find(const _Kt &__x) const -> decltype(const_iterator
Tries to locate an element in a set.
auto equal_range(const _Kt &__x) const -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
auto upper_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
Finds the end of a subsequence matching given key.
_Rep_type::const_reverse_iterator reverse_iterator
Iterator-related typedefs.
Struct holding two objects of arbitrary type.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from a set.
std::pair< iterator, bool > emplace(_Args &&... __args)
Attempts to build and insert an element into the set.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
allocator_type get_allocator() const noexcept
Returns the allocator object with which the set was constructed.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Attempts to insert an element into the set.
auto upper_bound(const _Kt &__x) const -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
Finds the end of a subsequence matching given key.