61 #include <initializer_list>
63 _GLIBCXX_BEGIN_NESTED_NAMESPACE(
std, _GLIBCXX_STD_D)
85 template<typename _Key, typename _Compare =
std::less<_Key>,
86 typename _Alloc =
std::allocator<_Key> >
90 typedef typename _Alloc::value_type _Alloc_value_type;
91 __glibcxx_class_requires(_Key, _SGIAssignableConcept)
92 __glibcxx_class_requires4(_Compare,
bool, _Key, _Key,
93 _BinaryFunctionConcept)
94 __glibcxx_class_requires2(_Key, _Alloc_value_type, _SameTypeConcept)
108 typedef typename _Alloc::template rebind<_Key>::other _Key_alloc_type;
110 typedef _Rb_tree<key_type, value_type, _Identity<value_type>,
111 key_compare, _Key_alloc_type> _Rep_type;
117 typedef typename _Key_alloc_type::pointer
pointer;
124 typedef typename _Rep_type::const_iterator
iterator;
145 set(
const _Compare& __comp,
146 const allocator_type& __a = allocator_type())
147 : _M_t(__comp, __a) { }
158 template<
typename _InputIterator>
159 set(_InputIterator __first, _InputIterator __last)
161 { _M_t._M_insert_unique(__first, __last); }
174 template<
typename _InputIterator>
175 set(_InputIterator __first, _InputIterator __last,
176 const _Compare& __comp,
177 const allocator_type& __a = allocator_type())
179 { _M_t._M_insert_unique(__first, __last); }
191 #ifdef __GXX_EXPERIMENTAL_CXX0X__
200 : _M_t(
std::forward<_Rep_type>(__x._M_t)) { }
212 set(initializer_list<value_type> __l,
213 const _Compare& __comp = _Compare(),
214 const allocator_type& __a = allocator_type())
216 { _M_t._M_insert_unique(__l.begin(), __l.end()); }
233 #ifdef __GXX_EXPERIMENTAL_CXX0X__
265 this->insert(__l.begin(), __l.end());
275 {
return _M_t.key_comp(); }
279 {
return _M_t.key_comp(); }
283 {
return _M_t.get_allocator(); }
292 {
return _M_t.begin(); }
301 {
return _M_t.end(); }
310 {
return _M_t.rbegin(); }
319 {
return _M_t.rend(); }
321 #ifdef __GXX_EXPERIMENTAL_CXX0X__
329 {
return _M_t.begin(); }
338 {
return _M_t.end(); }
347 {
return _M_t.rbegin(); }
356 {
return _M_t.rend(); }
362 {
return _M_t.empty(); }
367 {
return _M_t.size(); }
372 {
return _M_t.max_size(); }
386 #ifdef __GXX_EXPERIMENTAL_CXX0X__
391 { _M_t.swap(__x._M_t); }
411 _M_t._M_insert_unique(__x);
435 insert(iterator __position,
const value_type& __x)
436 {
return _M_t._M_insert_unique_(__position, __x); }
447 template<
typename _InputIterator>
449 insert(_InputIterator __first, _InputIterator __last)
450 { _M_t._M_insert_unique(__first, __last); }
452 #ifdef __GXX_EXPERIMENTAL_CXX0X__
462 { this->insert(__l.begin(), __l.end()); }
476 { _M_t.erase(__position); }
491 {
return _M_t.erase(__x); }
505 erase(iterator __first, iterator __last)
506 { _M_t.erase(__first, __last); }
530 {
return _M_t.find(__x) == _M_t.end() ? 0 : 1; }
548 {
return _M_t.find(__x); }
551 find(
const key_type& __x)
const
552 {
return _M_t.find(__x); }
569 {
return _M_t.lower_bound(__x); }
573 {
return _M_t.lower_bound(__x); }
585 {
return _M_t.upper_bound(__x); }
589 {
return _M_t.upper_bound(__x); }
610 {
return _M_t.equal_range(__x); }
614 {
return _M_t.equal_range(__x); }
617 template<
typename _K1,
typename _C1,
typename _A1>
621 template<
typename _K1,
typename _C1,
typename _A1>
637 template<
typename _Key,
typename _Compare,
typename _Alloc>
641 {
return __x._M_t == __y._M_t; }
654 template<
typename _Key,
typename _Compare,
typename _Alloc>
656 operator<(const set<_Key, _Compare, _Alloc>& __x,
658 {
return __x._M_t < __y._M_t; }
661 template<
typename _Key,
typename _Compare,
typename _Alloc>
665 {
return !(__x == __y); }
668 template<
typename _Key,
typename _Compare,
typename _Alloc>
672 {
return __y < __x; }
675 template<
typename _Key,
typename _Compare,
typename _Alloc>
677 operator<=(const set<_Key, _Compare, _Alloc>& __x,
679 {
return !(__y < __x); }
682 template<
typename _Key,
typename _Compare,
typename _Alloc>
686 {
return !(__x < __y); }
689 template<
typename _Key,
typename _Compare,
typename _Alloc>
694 #ifdef __GXX_EXPERIMENTAL_CXX0X__
695 template<
typename _Key,
typename _Compare,
typename _Alloc>
697 swap(set<_Key, _Compare, _Alloc>&& __x, set<_Key, _Compare, _Alloc>& __y)
700 template<
typename _Key,
typename _Compare,
typename _Alloc>
702 swap(set<_Key, _Compare, _Alloc>& __x, set<_Key, _Compare, _Alloc>&& __y)
706 _GLIBCXX_END_NESTED_NAMESPACE
value_compare value_comp() const
Returns the comparison object with which the set was constructed.
void erase(iterator __first, iterator __last)
Erases a [first,last) range of elements from a set.
_Rep_type::const_reverse_iterator reverse_iterator
Iterator-related typedefs.
std::pair< iterator, iterator > equal_range(const key_type &__x)
Finds a subsequence matching given key.
reverse_iterator crend() const
size_type size() const
Returns the size of the set.
_Alloc allocator_type
Public typedefs.
_Key_alloc_type::pointer pointer
Iterator-related typedefs.
bool operator==(const set< _Key, _Compare, _Alloc > &__x, const set< _Key, _Compare, _Alloc > &__y)
Set equality comparison.
size_type erase(const key_type &__x)
Erases elements according to the provided key.
allocator_type get_allocator() const
Returns the allocator object with which the set was constructed.
reverse_iterator rend() const
const_iterator find(const key_type &__x) const
Tries to locate an element in a set.
_T1 first
first is a copy of the first object
iterator find(const key_type &__x)
Tries to locate an element in a set.
ISO C++ entities toplevel namespace is std.
reverse_iterator rbegin() const
const_iterator lower_bound(const key_type &__x) const
Finds the beginning of a subsequence matching given key.
bool operator>(const set< _Key, _Compare, _Alloc > &__x, const set< _Key, _Compare, _Alloc > &__y)
Returns y < x.
_Rep_type::difference_type difference_type
Iterator-related typedefs.
_Rep_type::size_type size_type
Iterator-related typedefs.
_Key key_type
Public typedefs.
_T2 second
second is a copy of the second object
pair holds two objects of arbitrary type.
key_compare key_comp() const
Returns the comparison object with which the set was constructed.
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.
_Rep_type::const_iterator iterator
Iterator-related typedefs.
size_type count(const key_type &__x) const
Finds the number of elements.
bool operator!=(const set< _Key, _Compare, _Alloc > &__x, const set< _Key, _Compare, _Alloc > &__y)
Returns !(x == y).
const_iterator upper_bound(const key_type &__x) const
Finds the end of a subsequence matching given key.
_Key_alloc_type::reference reference
Iterator-related typedefs.
set(initializer_list< value_type > __l, const _Compare &__comp=_Compare(), const allocator_type &__a=allocator_type())
Builds a set from an initializer_list.
bool operator>=(const set< _Key, _Compare, _Alloc > &__x, const set< _Key, _Compare, _Alloc > &__y)
Returns !(x < y)
_Rep_type::const_iterator const_iterator
Iterator-related typedefs.
_Compare key_compare
Public typedefs.
set(const set &__x)
Set copy constructor.
_Key value_type
Public typedefs.
_Compare value_compare
Public typedefs.
set(set &&__x)
Set move constructor
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert an element into the set.
set()
Default constructor creates no elements.
void insert(initializer_list< value_type > __l)
Attempts to insert a list of elements into the set.
iterator upper_bound(const key_type &__x)
Finds the end of a subsequence matching given key.
_Key_alloc_type::const_reference const_reference
Iterator-related typedefs.
_Rep_type::const_reverse_iterator const_reverse_iterator
Iterator-related typedefs.
_Key_alloc_type::const_pointer const_pointer
Iterator-related typedefs.
set & operator=(set &&__x)
Set move assignment operator.
void erase(iterator __position)
Erases an element from a set.
size_type max_size() const
Returns the maximum size of the set.
set(_InputIterator __first, _InputIterator __last)
Builds a set from a range.
void swap(set &&__x)
Swaps data with another set.
reverse_iterator crbegin() const
set(_InputIterator __first, _InputIterator __last, const _Compare &__comp, const allocator_type &__a=allocator_type())
Builds a set from a range.
set(const _Compare &__comp, const allocator_type &__a=allocator_type())
Creates a set with no elements.
std::pair< const_iterator, const_iterator > equal_range(const key_type &__x) const
Finds a subsequence matching given key.
bool empty() const
Returns true if the set is empty.
A standard container made up of unique keys, which can be retrieved in logarithmic time...
iterator lower_bound(const key_type &__x)
Finds the beginning of a subsequence matching given key.
iterator insert(iterator __position, const value_type &__x)
Attempts to insert an element into the set.
set & operator=(const set &__x)
Set assignment operator.