Meets the requirements of a container, a reversible container, and an associative container (using unique keys).
Sets support bidirectional iterators.
Key | Type of key objects. | |
Compare | Comparison function object type, defaults to less<Key>. | |
Alloc | Allocator type, defaults to allocator<Key>. |
Definition at line 92 of file stl_set.h.
std::set< _Key, _Compare, _Alloc >::set | ( | const _Compare & | __comp, | |
const allocator_type & | __a = allocator_type() | |||
) | [inline, explicit] |
std::set< _Key, _Compare, _Alloc >::set | ( | _InputIterator | __first, | |
_InputIterator | __last | |||
) | [inline] |
Builds a set from a range.
first | An input iterator. | |
last | An input iterator. |
Definition at line 164 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::_M_insert_unique().
std::set< _Key, _Compare, _Alloc >::set | ( | _InputIterator | __first, | |
_InputIterator | __last, | |||
const _Compare & | __comp, | |||
const allocator_type & | __a = allocator_type() | |||
) | [inline] |
Builds a set from a range.
first | An input iterator. | |
last | An input iterator. | |
comp | A comparison functor. | |
a | An allocator object. |
Definition at line 180 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::_M_insert_unique().
iterator std::set< _Key, _Compare, _Alloc >::begin | ( | ) | const [inline] |
Returns a read-only (constant) iterator that points to the first element in the set. Iteration is done in ascending order according to the keys.
Definition at line 261 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::begin().
void std::set< _Key, _Compare, _Alloc >::clear | ( | ) | [inline] |
Erases all elements in a set. Note that this function only erases the elements, and that if the elements themselves are pointers, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.
Definition at line 471 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::clear().
size_type std::set< _Key, _Compare, _Alloc >::count | ( | const key_type & | __x | ) | const [inline] |
Finds the number of elements.
x | Element to located. |
Definition at line 485 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::end(), and std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::find().
bool std::set< _Key, _Compare, _Alloc >::empty | ( | ) | const [inline] |
Returns true if the set is empty.
Definition at line 331 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::empty().
iterator std::set< _Key, _Compare, _Alloc >::end | ( | ) | const [inline] |
Returns a read-only (constant) iterator that points one past the last element in the set. Iteration is done in ascending order according to the keys.
Definition at line 270 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::end().
std::pair<iterator, iterator> std::set< _Key, _Compare, _Alloc >::equal_range | ( | const key_type & | __x | ) | [inline] |
Finds a subsequence matching given key.
x | Key to be located. |
std::make_pair(c.lower_bound(val), c.upper_bound(val))
This function probably only makes sense for multisets.
Definition at line 565 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::equal_range().
void std::set< _Key, _Compare, _Alloc >::erase | ( | iterator | __first, | |
iterator | __last | |||
) | [inline] |
Erases a [first,last) range of elements from a set.
first | Iterator pointing to the start of the range to be erased. | |
last | Iterator pointing to the end of the range to be erased. |
Definition at line 461 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::erase().
size_type std::set< _Key, _Compare, _Alloc >::erase | ( | const key_type & | __x | ) | [inline] |
Erases elements according to the provided key.
x | Key of element to be erased. |
Definition at line 446 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::erase().
void std::set< _Key, _Compare, _Alloc >::erase | ( | iterator | __position | ) | [inline] |
Erases an element from a set.
position | An iterator pointing to the element to be erased. |
Definition at line 431 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::erase().
iterator std::set< _Key, _Compare, _Alloc >::find | ( | const key_type & | __x | ) | [inline] |
Tries to locate an element in a set.
x | Element to be located. |
end()
) iterator.
Definition at line 503 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::find().
allocator_type std::set< _Key, _Compare, _Alloc >::get_allocator | ( | ) | const [inline] |
Returns the allocator object with which the set was constructed.
Definition at line 252 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::get_allocator().
void std::set< _Key, _Compare, _Alloc >::insert | ( | _InputIterator | __first, | |
_InputIterator | __last | |||
) | [inline] |
A template function that attempts to insert a range of elements.
first | Iterator pointing to the start of the range to be inserted. | |
last | Iterator pointing to the end of the range. |
Definition at line 418 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::_M_insert_unique().
iterator std::set< _Key, _Compare, _Alloc >::insert | ( | iterator | __position, | |
const value_type & | __x | |||
) | [inline] |
Attempts to insert an element into the set.
position | An iterator that serves as a hint as to where the element should be inserted. | |
x | Element to be inserted. |
See http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html#4 for more on "hinting".
Insertion requires logarithmic time (if the hint is not taken).
Definition at line 405 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::_M_insert_unique_().
std::pair<iterator, bool> std::set< _Key, _Compare, _Alloc >::insert | ( | const value_type & | __x | ) | [inline] |
Attempts to insert an element into the set.
x | Element to be inserted. |
Insertion requires logarithmic time.
Definition at line 378 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::_M_insert_unique(), std::pair< _T1, _T2 >::first, and std::pair< _T1, _T2 >::second.
key_compare std::set< _Key, _Compare, _Alloc >::key_comp | ( | ) | const [inline] |
Returns the comparison object with which the set was constructed.
Definition at line 244 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::key_comp().
iterator std::set< _Key, _Compare, _Alloc >::lower_bound | ( | const key_type & | __x | ) | [inline] |
Finds the beginning of a subsequence matching given key.
x | Key to be located. |
Definition at line 524 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::lower_bound().
size_type std::set< _Key, _Compare, _Alloc >::max_size | ( | ) | const [inline] |
Returns the maximum size of the set.
Definition at line 341 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::max_size().
set& std::set< _Key, _Compare, _Alloc >::operator= | ( | const set< _Key, _Compare, _Alloc > & | __x | ) | [inline] |
Set assignment operator.
x | A set of identical element and allocator types. |
Definition at line 216 of file stl_set.h.
References std::set< _Key, _Compare, _Alloc >::_M_t.
reverse_iterator std::set< _Key, _Compare, _Alloc >::rbegin | ( | ) | const [inline] |
Returns a read-only (constant) iterator that points to the last element in the set. Iteration is done in descending order according to the keys.
Definition at line 279 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::rbegin().
reverse_iterator std::set< _Key, _Compare, _Alloc >::rend | ( | ) | const [inline] |
Returns a read-only (constant) reverse iterator that points to the last pair in the set. Iteration is done in descending order according to the keys.
Definition at line 288 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::rend().
size_type std::set< _Key, _Compare, _Alloc >::size | ( | ) | const [inline] |
Returns the size of the set.
Definition at line 336 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::size().
void std::set< _Key, _Compare, _Alloc >::swap | ( | set< _Key, _Compare, _Alloc > & | __x | ) | [inline] |
Swaps data with another set.
x | A set of the same element and allocator types. |
Compare
type (which itself is often stateless and empty), so it should be quite fast.) Note that the global std::swap() function is specialized such that std::swap(s1,s2) will feed to this function.
Definition at line 359 of file stl_set.h.
References std::set< _Key, _Compare, _Alloc >::_M_t, and std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::swap().
Referenced by std::swap().
iterator std::set< _Key, _Compare, _Alloc >::upper_bound | ( | const key_type & | __x | ) | [inline] |
Finds the end of a subsequence matching given key.
x | Key to be located. |
Definition at line 540 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::upper_bound().
value_compare std::set< _Key, _Compare, _Alloc >::value_comp | ( | ) | const [inline] |
Returns the comparison object with which the set was constructed.
Definition at line 248 of file stl_set.h.
References std::_Rb_tree< _Key, _Val, _KeyOfValue, _Compare, _Alloc >::key_comp().