The STL set represents an arbitrary collection of elements that can be queried for membership. set is useful in situations where you need to keep track of a collection of elements and must rapidly look up whether an element is contained.
The set does not store duplicates. For a similar container where duplicates are allowed, use the multiset.
By default, the set uses operator < to order the elements behind the scenes. To use an alternative comparison function, parametrize the set as set<T, CompareFunctorType>.
set.Constructs a new set. This is the default constructor.
Inserts new elements into the set. The first version of insert inserts a single element into the set. insert returns a pair<iterator, bool>, where the first field of the pair is an iterator to the element and the second field is a bool representing whether the element was inserted. If the element already existed, this value will be false; if the element was created for the first time, it will be true.
The second version of this function inserts a range of elements into the set, removing duplicates.
Returns an iterator to the specified element, if it exists, and the result of the set's end function otherwise.
setReturns 1 if the specified element is contained in the set and 0 otherwise. count is a useful function, but in practice it's far more common to see find.
setRemoves elements from the set. The first version removes the specified element from the set, returning 1 if the element existed and was removed and 0 otherwise. The second version removes from the set the element pointed at by the specified iterator. The third version removes all elements in the range [start, stop) from the set.
Returns whether the set is empty. It's considered good practice to call empty to determine whether the set is empty rather than checking whether size() returns zero.
Removes all elements from the set.
Returns the number of elements stored in the set.
Returns an iterator to the first element in the set. Elements in a set are stored in sorted order, so the elements returned by iterating over the set will be sorted.
Returns an iterator to the element one past the end of the set. This iterator does not point to a valid element, so do not dereference it.
setsetConstructs a new set whose elements are equal to the elements defined in the range [begin, end). These iterators need not come from another set.
Returns an iterator to the first element greater than or equal to the parameter. If no elements are found, lower_bound returns end().
Returns an iterator to the first element that compares strictly greater than the parameter.
Returns an pair of iterators defining the range containing the single element specified as a parameter. If the element does not exist, the two iterators will be equal.
Returns the maximum number of elements the set can hold, which is usually the number of unique memory addresses divided by the size of the elements stored in the container.
Returns the set's internal comparison function used to compare two elements. You can use this function to compare two elements in the same way as the set.
This function is identical to key_comp.
Returns a reverse_iterator to the last element of the set. reverse_iterators are like regular iterators except that they traverse in the opposite direction. Check for the end-of-container condition of reverse_iterators with rend.
Returns a reverse_iterator to the element one element before the start of the array. Like end, the iterator returned by rend does not actually reference a real element of the set and you should take care not to actually dereference it.
setssExchanges the contents of this set and another set.