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)
115 rebind<_Key>::other _Key_alloc_type;
117 typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
126 typedef typename _Alloc_traits::pointer
pointer;
133 typedef typename _Rep_type::const_iterator
iterator;
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); }
205 #if __cplusplus < 201103L 209 set(
const set&) =
default;
217 set(
set&&) =
default;
230 const _Compare& __comp = _Compare(),
232 : _M_t(__comp, _Key_alloc_type(__a))
233 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
237 set(
const allocator_type& __a)
238 : _M_t(_Compare(), _Key_alloc_type(__a)) { }
241 set(
const set& __x,
const allocator_type& __a)
242 : _M_t(__x._M_t, _Key_alloc_type(__a)) { }
245 set(
set&& __x,
const allocator_type& __a)
246 noexcept(is_nothrow_copy_constructible<_Compare>::value
247 && _Alloc_traits::_S_always_equal())
248 : _M_t(std::move(__x._M_t), _Key_alloc_type(__a)) { }
252 : _M_t(_Compare(), _Key_alloc_type(__a))
253 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
256 template<
typename _InputIterator>
257 set(_InputIterator __first, _InputIterator __last,
258 const allocator_type& __a)
259 : _M_t(_Compare(), _Key_alloc_type(__a))
260 { _M_t._M_insert_unique(__first, __last); }
275 #if __cplusplus < 201103L 304 _M_t._M_assign_unique(__l.begin(), __l.end());
314 {
return _M_t.key_comp(); }
318 {
return _M_t.key_comp(); }
331 {
return _M_t.begin(); }
339 end() const _GLIBCXX_NOEXCEPT
340 {
return _M_t.end(); }
349 {
return _M_t.rbegin(); }
358 {
return _M_t.rend(); }
360 #if __cplusplus >= 201103L 368 {
return _M_t.begin(); }
377 {
return _M_t.end(); }
386 {
return _M_t.rbegin(); }
395 {
return _M_t.rend(); }
401 {
return _M_t.empty(); }
406 {
return _M_t.size(); }
411 {
return _M_t.max_size(); }
428 _GLIBCXX_NOEXCEPT_IF(__is_nothrow_swappable<_Compare>::value)
429 { _M_t.swap(__x._M_t); }
432 #if __cplusplus >= 201103L 446 template<
typename... _Args>
449 {
return _M_t._M_emplace_unique(std::forward<_Args>(__args)...); }
472 template<
typename... _Args>
476 return _M_t._M_emplace_hint_unique(__pos,
477 std::forward<_Args>(__args)...);
498 _M_t._M_insert_unique(__x);
502 #if __cplusplus >= 201103L 507 _M_t._M_insert_unique(std::move(__x));
532 insert(const_iterator __position,
const value_type& __x)
533 {
return _M_t._M_insert_unique_(__position, __x); }
535 #if __cplusplus >= 201103L 537 insert(const_iterator __position, value_type&& __x)
538 {
return _M_t._M_insert_unique_(__position, std::move(__x)); }
550 template<
typename _InputIterator>
552 insert(_InputIterator __first, _InputIterator __last)
553 { _M_t._M_insert_unique(__first, __last); }
555 #if __cplusplus >= 201103L 565 { this->
insert(__l.begin(), __l.end()); }
568 #if __cplusplus > 201402L 571 extract(const_iterator __pos)
573 __glibcxx_assert(__pos !=
end());
574 return _M_t.extract(__pos);
579 extract(
const key_type& __x)
580 {
return _M_t.extract(__x); }
585 {
return _M_t._M_reinsert_node_unique(std::move(__nh)); }
589 insert(const_iterator __hint, node_type&& __nh)
590 {
return _M_t._M_reinsert_node_hint_unique(__hint, std::move(__nh)); }
592 template<
typename,
typename>
593 friend class _Rb_tree_merge_helper;
595 template<
typename _Compare1>
599 using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
600 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
603 template<
typename _Compare1>
608 template<
typename _Compare1>
612 using _Merge_helper = _Rb_tree_merge_helper<set, _Compare1>;
613 _M_t._M_merge_unique(_Merge_helper::_S_get_tree(__source));
616 template<
typename _Compare1>
622 #if __cplusplus >= 201103L 638 _GLIBCXX_ABI_TAG_CXX11
641 {
return _M_t.erase(__position); }
654 erase(iterator __position)
655 { _M_t.erase(__position); }
671 {
return _M_t.erase(__x); }
673 #if __cplusplus >= 201103L 690 _GLIBCXX_ABI_TAG_CXX11
692 erase(const_iterator __first, const_iterator __last)
693 {
return _M_t.erase(__first, __last); }
708 erase(iterator __first, iterator __last)
709 { _M_t.erase(__first, __last); }
735 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
737 #if __cplusplus > 201103L 738 template<
typename _Kt>
741 -> decltype(_M_t._M_count_tr(__x))
742 {
return _M_t._M_count_tr(__x); }
762 {
return _M_t.find(__x); }
765 find(
const key_type& __x)
const 766 {
return _M_t.find(__x); }
768 #if __cplusplus > 201103L 769 template<
typename _Kt>
772 -> decltype(iterator{_M_t._M_find_tr(__x)})
773 {
return iterator{_M_t._M_find_tr(__x)}; }
775 template<
typename _Kt>
778 -> decltype(const_iterator{_M_t._M_find_tr(__x)})
779 {
return const_iterator{_M_t._M_find_tr(__x)}; }
797 {
return _M_t.lower_bound(__x); }
801 {
return _M_t.lower_bound(__x); }
803 #if __cplusplus > 201103L 804 template<
typename _Kt>
807 -> decltype(
iterator(_M_t._M_lower_bound_tr(__x)))
808 {
return iterator(_M_t._M_lower_bound_tr(__x)); }
810 template<
typename _Kt>
827 {
return _M_t.upper_bound(__x); }
831 {
return _M_t.upper_bound(__x); }
833 #if __cplusplus > 201103L 834 template<
typename _Kt>
837 -> decltype(
iterator(_M_t._M_upper_bound_tr(__x)))
838 {
return iterator(_M_t._M_upper_bound_tr(__x)); }
840 template<
typename _Kt>
843 -> decltype(
iterator(_M_t._M_upper_bound_tr(__x)))
866 {
return _M_t.equal_range(__x); }
870 {
return _M_t.equal_range(__x); }
872 #if __cplusplus > 201103L 873 template<
typename _Kt>
879 template<
typename _Kt>
887 template<
typename _K1,
typename _C1,
typename _A1>
891 template<
typename _K1,
typename _C1,
typename _A1>
907 template<
typename _Key,
typename _Compare,
typename _Alloc>
911 {
return __x._M_t == __y._M_t; }
924 template<
typename _Key,
typename _Compare,
typename _Alloc>
926 operator<(const set<_Key, _Compare, _Alloc>& __x,
928 {
return __x._M_t < __y._M_t; }
931 template<
typename _Key,
typename _Compare,
typename _Alloc>
935 {
return !(__x == __y); }
938 template<
typename _Key,
typename _Compare,
typename _Alloc>
942 {
return __y < __x; }
945 template<
typename _Key,
typename _Compare,
typename _Alloc>
947 operator<=(const set<_Key, _Compare, _Alloc>& __x,
949 {
return !(__y < __x); }
952 template<
typename _Key,
typename _Compare,
typename _Alloc>
956 {
return !(__x < __y); }
959 template<
typename _Key,
typename _Compare,
typename _Alloc>
962 _GLIBCXX_NOEXCEPT_IF(noexcept(__x.swap(__y)))
965 _GLIBCXX_END_NAMESPACE_CONTAINER
967 #if __cplusplus > 201402L 968 _GLIBCXX_BEGIN_NAMESPACE_VERSION
970 template<
typename _Val,
typename _Cmp1,
typename _Alloc,
typename _Cmp2>
972 _Rb_tree_merge_helper<_GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>, _Cmp2>
975 friend class _GLIBCXX_STD_C::set<_Val, _Cmp1, _Alloc>;
978 _S_get_tree(_GLIBCXX_STD_C::set<_Val, _Cmp2, _Alloc>& __set)
979 {
return __set._M_t; }
982 _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set)
983 {
return __set._M_t; }
985 _GLIBCXX_END_NAMESPACE_VERSION
size_type size() const noexcept
Returns the size of the set.
_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.
iterator end() const noexcept
auto count(const _Kt &__x) const -> decltype(_M_t._M_count_tr(__x))
Finds the number of elements.
set & operator=(initializer_list< value_type > __l)
Set list assignment operator.
_Rep_type::difference_type difference_type
Iterator-related typedefs.
const_iterator find(const key_type &__x) const
Tries to locate an element in a set.
allocator_type get_allocator() const noexcept
Returns the allocator object with which the set was constructed.
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.
bool empty() const noexcept
Returns true if the set is empty.
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
iterator cend() const noexcept
value_compare value_comp() const
Returns the comparison object with which the set was constructed.
_Alloc allocator_type
Public typedefs.
ISO C++ entities toplevel namespace is std.
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.
iterator find(const key_type &__x)
Tries to locate an element in a set.
key_compare key_comp() const
Returns the comparison object with which the set was constructed.
reverse_iterator rbegin() const noexcept
_Rep_type::const_iterator iterator
Iterator-related typedefs.
auto find(const _Kt &__x) -> decltype(iterator
Tries to locate an element in a set.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the set.
set & operator=(const set &)=default
Set assignment operator.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __first, const_iterator __last)
Erases a [__first,__last) range of elements from a set.
_GLIBCXX_ABI_TAG_CXX11 iterator erase(const_iterator __position)
Erases an element from a set.
_Alloc_traits::const_pointer const_pointer
Iterator-related typedefs.
_Alloc_traits::pointer pointer
Iterator-related typedefs.
auto upper_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_upper_bound_tr(__x)))
Finds the end of a subsequence matching given key.
bool operator==(const set< _Key, _Compare, _Alloc > &__x, const set< _Key, _Compare, _Alloc > &__y)
Set equality comparison.
A standard container made up of elements, which can be retrieved in logarithmic time.
auto equal_range(const _Kt &__x) -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.
auto find(const _Kt &__x) const -> decltype(const_iterator
Tries to locate an element in a set.
auto lower_bound(const _Kt &__x) -> decltype(iterator(_M_t._M_lower_bound_tr(__x)))
Finds the beginning of a subsequence matching given key.
_Compare key_compare
Public typedefs.
_Alloc_traits::const_reference const_reference
Iterator-related typedefs.
_Key value_type
Public typedefs.
bool operator!=(const set< _Key, _Compare, _Alloc > &__x, const set< _Key, _Compare, _Alloc > &__y)
Returns !(x == y).
std::pair< iterator, bool > emplace(_Args &&... __args)
Attempts to build and insert an element into the set.
_Rep_type::size_type size_type
Iterator-related typedefs.
reverse_iterator crend() const noexcept
size_type max_size() const noexcept
Returns the maximum size of the set.
void insert(_InputIterator __first, _InputIterator __last)
A template function that attempts to insert a range of elements.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
reverse_iterator crbegin() const noexcept
_Alloc_traits::reference reference
Iterator-related typedefs.
iterator cbegin() const noexcept
_Key key_type
Public typedefs.
size_type count(const key_type &__x) const
Finds the number of elements.
_Compare value_compare
Public typedefs.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert an element into the set.
A standard container made up of unique keys, which can be retrieved in logarithmic time...
_T1 first
second_type is the second bound type
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
iterator begin() const noexcept
_Rep_type::const_iterator const_iterator
Iterator-related typedefs.
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.
_Rep_type::const_reverse_iterator reverse_iterator
Iterator-related typedefs.
Struct holding two objects of arbitrary type.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
reverse_iterator rend() const noexcept
Uniform interface to C++98 and C++11 allocators.
iterator insert(const_iterator __position, const value_type &__x)
Attempts to insert an element into the set.
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
iterator emplace_hint(const_iterator __pos, _Args &&... __args)
Attempts to insert an element into the set.
bool operator>=(const set< _Key, _Compare, _Alloc > &__x, const set< _Key, _Compare, _Alloc > &__y)
Returns !(x < y)
_Rep_type::const_reverse_iterator const_reverse_iterator
Iterator-related typedefs.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
auto equal_range(const _Kt &__x) const -> decltype(pair< iterator, iterator >(_M_t._M_equal_range_tr(__x)))
Finds a subsequence matching given key.