libstdc++
|
A standard container made up of unique keys, which can be retrieved in logarithmic time.
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>. |
The private tree data is declared exactly the same way for set and multiset; the distinction is made entirely in how the tree functions are called (*_unique versus *_equal, same as the standard).
typedef _Alloc std::set::allocator_type |
typedef _Rep_type::const_iterator std::set::const_iterator |
typedef _Key_alloc_type::const_pointer std::set::const_pointer |
typedef _Key_alloc_type::const_reference std::set::const_reference |
typedef _Rep_type::difference_type std::set::difference_type |
typedef _Rep_type::const_iterator std::set::iterator |
typedef _Compare std::set::key_compare |
typedef _Key std::set::key_type |
typedef _Key_alloc_type::pointer std::set::pointer |
typedef _Key_alloc_type::reference std::set::reference |
typedef _Rep_type::size_type std::set::size_type |
typedef _Compare std::set::value_compare |
typedef _Key std::set::value_type |
std::set::set | ( | ) | [inline] |
std::set::set | ( | const _Compare & | __comp, |
const allocator_type & | __a = allocator_type() |
||
) | [inline, explicit] |
std::set::set | ( | _InputIterator | __first, |
_InputIterator | __last | ||
) | [inline] |
Builds a set from a range.
first | An input iterator. |
last | An input iterator. |
Create a set consisting of copies of the elements from [first,last). This is linear in N if the range is already sorted, and NlogN otherwise (where N is distance(first,last)).
std::set::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. |
Create a set consisting of copies of the elements from [first,last). This is linear in N if the range is already sorted, and NlogN otherwise (where N is distance(first,last)).
std::set::set | ( | const set & | __x | ) | [inline] |
std::set::set | ( | set && | __x | ) | [inline] |
std::set::set | ( | initializer_list< value_type > | __l, |
const _Compare & | __comp = _Compare() , |
||
const allocator_type & | __a = allocator_type() |
||
) | [inline] |
Builds a set from an initializer_list.
l | An initializer_list. |
comp | A comparison functor. |
a | An allocator object. |
Create a set consisting of copies of the elements in the list. This is linear in N if the list is already sorted, and NlogN otherwise (where N is l.size()).
iterator std::set::begin | ( | ) | const [inline] |
iterator std::set::cbegin | ( | ) | const [inline] |
iterator std::set::cend | ( | ) | const [inline] |
void std::set::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 572 of file stl_set.h.
Referenced by std::set< _StateIdT >::operator=().
reverse_iterator std::set::crbegin | ( | ) | const [inline] |
reverse_iterator std::set::crend | ( | ) | const [inline] |
bool std::set::empty | ( | ) | const [inline] |
iterator std::set::end | ( | ) | const [inline] |
Finds a subsequence matching given key.
x | Key to be located. |
This function is equivalent to
std::make_pair(c.lower_bound(val), c.upper_bound(val))
(but is faster than making the calls separately).
This function probably only makes sense for multisets.
std::pair<const_iterator, const_iterator> std::set::equal_range | ( | const key_type & | __x | ) | const [inline] |
Finds a subsequence matching given key.
x | Key to be located. |
This function is equivalent to
std::make_pair(c.lower_bound(val), c.upper_bound(val))
(but is faster than making the calls separately).
This function probably only makes sense for multisets.
iterator std::set::erase | ( | const_iterator | __position | ) | [inline] |
Erases an element from a set.
position | An iterator pointing to the element to be erased. |
This function erases an element, pointed to by the given iterator, from a set. Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.
Erases elements according to the provided key.
x | Key of element to be erased. |
This function erases all the elements located by the given key from a set. Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.
iterator std::set::erase | ( | const_iterator | __first, |
const_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. |
This function erases a sequence of elements from a set. Note that this function only erases the element, and that if the element is itself a pointer, the pointed-to memory is not touched in any way. Managing the pointer is the user's responsibility.
Tries to locate an element in a set.
x | Element to be located. |
This function takes a key and tries to locate the element with which the key matches. If successful the function returns an iterator pointing to the sought after element. If unsuccessful it returns the past-the-end ( end()
) iterator.
const_iterator std::set::find | ( | const key_type & | __x | ) | const [inline] |
Tries to locate an element in a set.
x | Element to be located. |
This function takes a key and tries to locate the element with which the key matches. If successful the function returns an iterator pointing to the sought after element. If unsuccessful it returns the past-the-end ( end()
) iterator.
allocator_type std::set::get_allocator | ( | ) | const [inline] |
std::pair<iterator, bool> std::set::insert | ( | const value_type & | __x | ) | [inline] |
Attempts to insert an element into the set.
x | Element to be inserted. |
This function attempts to insert an element into the set. A set relies on unique keys and thus an element is only inserted if it is not already present in the set.
Insertion requires logarithmic time.
Definition at line 407 of file stl_set.h.
Referenced by std::set< _StateIdT >::operator=().
iterator std::set::insert | ( | const_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. |
This function is not concerned about whether the insertion took place, and thus does not return a boolean like the single-argument insert() does. Note that the first parameter is only a hint and can potentially improve the performance of the insertion process. A bad hint would cause no gains in efficiency.
For more on hinting, see: http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt07ch17.html
Insertion requires logarithmic time (if the hint is not taken).
void std::set::insert | ( | _InputIterator | __first, |
_InputIterator | __last | ||
) | [inline] |
void std::set::insert | ( | initializer_list< value_type > | __l | ) | [inline] |
Attempts to insert a list of elements into the set.
list | A std::initializer_list<value_type> of elements to be inserted. |
Complexity similar to that of the range constructor.
Definition at line 476 of file stl_set.h.
Referenced by std::set< _StateIdT >::insert().
key_compare std::set::key_comp | ( | ) | const [inline] |
Finds the beginning of a subsequence matching given key.
x | Key to be located. |
This function returns the first element of a subsequence of elements that matches the given key. If unsuccessful it returns an iterator pointing to the first element that has a greater value than given key or end() if no such element exists.
const_iterator std::set::lower_bound | ( | const key_type & | __x | ) | const [inline] |
Finds the beginning of a subsequence matching given key.
x | Key to be located. |
This function returns the first element of a subsequence of elements that matches the given key. If unsuccessful it returns an iterator pointing to the first element that has a greater value than given key or end() if no such element exists.
size_type std::set::max_size | ( | ) | const [inline] |
set& std::set::operator= | ( | initializer_list< value_type > | __l | ) | [inline] |
Set list assignment operator.
l | An initializer_list. |
This function fills a set with copies of the elements in the initializer list l.
Note that the assignment completely changes the set and that the resulting set's size is the same as the number of elements assigned. Old data may be lost.
reverse_iterator std::set::rbegin | ( | ) | const [inline] |
reverse_iterator std::set::rend | ( | ) | const [inline] |
size_type std::set::size | ( | ) | const [inline] |
void std::set::swap | ( | set & | __x | ) | [inline] |
Swaps data with another set.
x | A set of the same element and allocator types. |
This exchanges the elements between two sets in constant time. (It is only swapping a pointer, an integer, and an instance of the 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 389 of file stl_set.h.
Referenced by std::set< _StateIdT >::operator=().
const_iterator std::set::upper_bound | ( | const key_type & | __x | ) | const [inline] |
value_compare std::set::value_comp | ( | ) | const [inline] |