# <set>
<set>
# ``
* * *
Include the [STL](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_index.html#STL)
standard header **``** to define the
[container](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_cont.html#Containers)
template classes `set` and
`multiset`, and their supporting
templates.
namespace std {
template
class set;
template
class multiset;
// TEMPLATE FUNCTIONS
template
bool operator==(
const set& left,
const set& right);
template
bool operator==(
const multiset& left,
const multiset& right);
template
bool operator!=(
const set& left,
const set& right);
template
bool operator!=(
const multiset& left,
const multiset& right);
template
bool operator<(
const set& left,
const set& right);
template
bool operator<(
const multiset& left,
const multiset& right);
template
bool operator>(
const set& left,
const set& right);
template
bool operator>(
const multiset& left,
const multiset& right);
template
bool operator<=(
const set& left,
const set& right);
template
bool operator<=(
const multiset& left,
const multiset& right);
template
bool operator>=(
const set& left,
const set& right);
template
bool operator>=(
const multiset& left,
const multiset& right);
template
void swap(
set& left,
set& right);
template
void swap(
multiset& left,
multiset& right);
} // namespace stdCopy to clipboard
## `multiset`
* * *
**`allocator_type· begin· clear· const_iterator· const_pointer· const_reference· const_reverse_iterator· count· difference_type· empty· end· equal_range· erase· find· get_allocator· insert· iterator· key_comp· key_compare· key_type· lower_bound· max_size· multiset· pointer· rbegin· reference· rend· reverse_iterator· size· size_type· swap· upper_bound· value_comp· value_compare· value_type`**
* * *
template,
class Alloc = allocator >
class multiset {
public:
typedef Key key_type;
typedef Pr key_compare;
typedef Key value_type;
typedef Pr value_compare;
typedef Allov allocator_type;
typedef Alloc::pointer pointer;
typedef Alloc::const_pointer const_pointer;
typedef Alloc::reference reference;
typedef Alloc::const_reference const_reference;
typedef T0 iterator;
typedef T1 const_iterator;
typedef T2 size_type;
typedef T3 difference_type;
typedef reverse_iterator
const_reverse_iterator;
typedef reverse_iterator reverse_iterator;
multiset();
explicit multiset(const Pr& pred);
multiset(const Pr& pred, const Alloc& al);
multiset(const multiset& right);
template
multiset(InIt first, InIt last);
template
multiset(InIt first, InIt last,
const Pr& pred);
template
multiset(InIt first, InIt last,
const Pr& pred, const Alloc& al);
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
reverse_iterator rend();
const_reverse_iterator rend() const;
size_type max_size() const;
bool empty() const;
Alloc get_allocator() const;
iterator insert(const value_type& val);
iterator insert(iterator where, const value_type& val);
template
void insert(InIt first, InIt last);
iterator erase(iterator where);
iterator erase(iterator first, iterator last);
size_type erase(const Key& keyval);
void clear();
void swap(multiset& right);
key_compare key_comp() const;
value_compare value_comp() const;
iterator find(const Key& keyval);
const_iterator find(const Key& keyval) const;
size_type count(const Key& keyval) const;
iterator lower_bound(const Key& keyval);
const_iterator lower_bound(const Key& keyval) const;
iterator upper_bound(const Key& keyval);
const_iterator upper_bound(const Key& keyval) const;
pair equal_range(const Key& keyval);
pair
equal_range(const Key& keyval) const;
};Copy to clipboard
The template class describes an object that controls a
varying-length sequence of elements of type
`const Key`.
The sequence is
[ordered by](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_stl.html#sequence%20ordering) the predicate
`Pr`.
Each element serves as both a **sort key** and a **value**.
The sequence is represented in a way that permits lookup, insertion,
and removal of an arbitrary element with a number of operations
proportional to the logarithm of the number of elements
in the sequence (logarithmic time). Moreover, inserting an element
invalidates no iterators, and removing an element
invalidates only those iterators which point at the removed element.
The object orders the sequence it controls by calling a
stored **function object** of type `Pr`. You access
this stored object by calling the member function
`key_comp()`.
Such a function object must impose a
[strict weak ordering](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_stl.html#strict%20weak%20ordering)
on sort keys of type `Key`.
For any element `X` that precedes
`Y` in the sequence,
`key_comp()(Y, X)` is false. (For the default function object
`less`,
sort keys never decrease in value.)
Unlike template class `set`,
an object of template class `multiset` does not ensure that
`key_comp()(X, Y)` is true.
(Keys need not be unique.)
The object allocates and frees storage for the sequence it controls
through a stored [allocator object](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_memory.html#allocator%20object)
of class `Alloc`. Such an allocator object must have
the same external interface as an object of template class
[`allocator`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_memory.html#allocator).
Note that the stored allocator object is *not* copied when the container
object is assigned.
### `multiset::allocator_type`
typedef Alloc allocator_type;Copy to clipboard
The type is a synonym for the template parameter `Alloc`.
### `multiset::begin`
iterator begin();
const_iterator begin() const;Copy to clipboard
The member function returns a bidirectional iterator that points at
the first element of the sequence (or just beyond the end of an empty
sequence).
### `multiset::clear`
void clear();Copy to clipboard
The member function calls
`erase(
begin(),
end())`.
### `multiset::const_iterator`
typedef T1 const_iterator;Copy to clipboard
The type describes an object that can serve as a constant
bidirectional iterator for the controlled sequence.
It is described here as a
synonym for the implementation-defined type `T1`.
### `multiset::const_pointer`
typedef Alloc::const_pointer const_pointer;Copy to clipboard
The type describes an object that can serve as a constant pointer
to an element of the controlled sequence.
### `multiset::const_reference`
typedef Alloc::const_reference const_reference;Copy to clipboard
The type describes an object that can serve as a constant reference
to an element of the controlled sequence.
### `multiset::const_reverse_iterator`
typedef reverse_iterator
const_reverse_iterator;Copy to clipboard
The type describes an object that can serve as a constant reverse
bidirectional iterator for the controlled sequence.
### `multiset::count`
size_type count(const Key& keyval) const;Copy to clipboard
The member function returns the number of elements
in the range
`[lower_bound(keyval),
upper_bound(keyval)).`
### `multiset::difference_type`
typedef T3 difference_type;Copy to clipboard
The signed integer type describes an object that can represent the
difference between the addresses of any two elements in the controlled
sequence. It is described here as a
synonym for the implementation-defined type `T3`.
### `multiset::empty`
bool empty() const;Copy to clipboard
The member function returns true for an empty controlled sequence.
### `multiset::end`
iterator end();
const_iterator end() const;Copy to clipboard
The member function returns a bidirectional iterator that points
just beyond the end of the sequence.
### `multiset::equal_range`
pair
equal_range(const Key& keyval);
pair
equal_range(const Key& keyval) const;Copy to clipboard
The member function returns a pair of iterators `X`
such that `X.first ==
lower_bound(keyval)`
and `X.second ==
upper_bound(keyval)`.
### `multiset::erase`
iterator erase(iterator where);
iterator erase(iterator first, iterator last);
size_type erase(const Key& keyval);Copy to clipboard
The first member function removes the element of the controlled
sequence pointed to by `where`.
The second member function removes the elements
in the range `[first, last)`.
Both return an iterator that designates the first element remaining
beyond any elements removed, or
`end()` if no such element exists.
The third member removes
the elements with sort keys in the range
`[lower_bound(keyval),
upper_bound(keyval)).`
It returns the number of elements it removes.
The member functions never throw an exception.
In this
[implementation](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_index.html#implementation), the first two
member functions return an iterator that designates the first element remaining
beyond any elements removed, or
`end()` if no such element exists.
### `multiset::find`
iterator find(const Key& keyval);
const_iterator find(const Key& keyval) const;Copy to clipboard
The member function returns an iterator that designates
the earliest element in the controlled sequence whose sort key has
[equivalent ordering](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_stl.html#equivalent%20ordering)
to `keyval`. If no such element exists,
the function returns
`end()`.
### `multiset::get_allocator`
Alloc get_allocator() const;Copy to clipboard
The member function returns the stored
[allocator object](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_memory.html#allocator%20object).
### `multiset::insert`
iterator insert(const value_type& val);
iterator insert(iterator where, const value_type& val);
template
void insert(InIt first, InIt last);Copy to clipboard
The first member function inserts the element `val`
in the controlled sequence, then returns
the iterator that designates the inserted element.
The second member function returns `insert(val)`,
using `where` as a starting place within the controlled
sequence to search for the insertion point. (Insertion can occur
in amortized constant time, instead of logarithmic time, if the
insertion point immediately precedes or follows `where`.)
The third member function
inserts the sequence of element values,
for each `it` in the range `[first, last)`,
by calling `insert(*where)`.
If an exception is thrown during the
insertion of a single element, the container is left unaltered
and the exception is rethrown.
If an exception is thrown during the
insertion of multiple elements, the container is left in a stable
but unspecified state and the exception is rethrown.
### `multiset::iterator`
typedef T0 iterator;Copy to clipboard
The type describes an object that can serve as a bidirectional
iterator for the controlled sequence.
It is described here as a
synonym for the implementation-defined type `T0`.
### `multiset::key_comp`
key_compare key_comp() const;Copy to clipboard
The member function returns the stored function object that
determines the order of elements in the controlled sequence.
The stored object defines the member function:
bool operator(const Key& left, const Key& right);Copy to clipboard
which returns true if `left` strictly
precedes `right` in the sort order.
### `multiset::key_compare`
typedef Pr key_compare;Copy to clipboard
The type describes a function object that can compare two
sort keys to determine the relative order of two
elements in the controlled sequence.
### `multiset::key_type`
typedef Key key_type;Copy to clipboard
The type describes the sort key object which constitutes each
element of the controlled sequence.
### `multiset::lower_bound`
iterator lower_bound(const Key& keyval);
const_iterator lower_bound(const Key& keyval) const;Copy to clipboard
The member function returns an iterator that designates the
earliest element `X` in the controlled sequence for which
`key_comp()(X, keyval)` is
false.
If no such element exists, the function returns
`end()`.
### `multiset::multiset`
multiset();
explicit multiset(const Pr& pred);
multiset(const Pr& pred, const Alloc& al);
multiset(const multiset& right);
template
multiset(InIt first, InIt last);
template
multiset(InIt first, InIt last,
const Pr& pred);
template
multiset(InIt first, InIt last,
const Pr& pred, const Alloc& al);Copy to clipboard
All constructors store an
[allocator object](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_memory.html#allocator%20object) and
initialize the controlled sequence. The allocator object is the argument
`al`, if present. For the copy constructor, it is
`right.get_allocator()`.
Otherwise, it is `Alloc()`.
All constructors also store a function object that can later
be returned by calling
`key_comp()`.
The function object is the argument `pred`, if present.
For the copy constructor, it is
`right.key_comp()`).
Otherwise, it is `Pr()`.
The first three constructors specify an
empty initial controlled sequence. The fourth constructor specifies
a copy of the sequence controlled by `right`.
The last three constructors specify the sequence of element values
`[first, last)`.
### `multiset::max_size`
size_type max_size() const;Copy to clipboard
The member function returns the length of the longest sequence that
the object can control.
### `multiset::pointer`
typedef Alloc::pointer pointer;Copy to clipboard
The type describes an object that can serve as a pointer to an
element of the controlled sequence.
### `multiset::rbegin`
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;Copy to clipboard
The member function returns a reverse bidirectional
iterator that points just
beyond the end of the controlled sequence. Hence, it designates the
beginning of the reverse sequence.
### `multiset::reference`
typedef Alloc::reference reference;Copy to clipboard
The type describes an object that can serve as a reference to an
element of the controlled sequence.
### `multiset::rend`
reverse_iterator rend();
const_reverse_iterator rend() const;Copy to clipboard
The member function returns a reverse bidirectional
iterator that points at the
first element of the sequence (or just beyond the end of an empty
sequence). Hence, it designates the end of the reverse sequence.
### `multiset::reverse_iterator`
typedef reverse_iterator reverse_iterator;Copy to clipboard
The type describes an object that can serve as a reverse
bidirectional iterator for the controlled sequence.
### `multiset::size`
size_type size() const;Copy to clipboard
The member function returns the length of the controlled sequence.
### `multiset::size_type`
typedef T2 size_type;Copy to clipboard
The unsigned integer type describes an object that can represent the
length of any controlled sequence. It is described here as a
synonym for the implementation-defined type `T2`.
### `multiset::swap`
void swap(multiset& right);Copy to clipboard
The member function swaps the controlled sequences between
`*this` and `right`. If
`get_allocator()
== right.get_allocator()`, it does so in constant time,
it throws an exception only as a result of copying the stored
function object of type `Pr`, and it invalidates no references, pointers,
or iterators that designate elements in the two controlled sequences.
Otherwise, it performs a number of element assignments and constructor calls
proportional to the number of elements in the two controlled sequences.
### `multiset::upper_bound`
iterator upper_bound(const Key& keyval)
const_iterator upper_bound(const Key& keyval) const;Copy to clipboard
The member function returns an iterator that designates the
earliest element `X` in the controlled sequence for which
`key_comp()(keyval, X)` is
true.
If no such element exists, the function returns
`end()`.
### `multiset::value_comp`
value_compare value_comp() const;Copy to clipboard
The member function returns a function object that
determines the order of elements in the controlled sequence.
### `multiset::value_compare`
typedef Pr value_compare;Copy to clipboard
The type describes a function object that can compare two
elements as sort keys to determine their relative order
in the controlled sequence.
### `multiset::value_type`
typedef Key value_type;Copy to clipboard
The type describes an element of the controlled sequence.
## `operator!=`
template
bool operator!=(
const set & left,
const set & right);
template
bool operator!=(
const multiset & left,
const multiset & right);Copy to clipboard
The template function returns `!(left == right)`.
## `operator==`
template
bool operator==(
const set & left,
const set & right);
template
bool operator==(
const multiset & left,
const multiset & right);Copy to clipboard
The first template function overloads `operator==`
to compare two objects of template class
[`set`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_set.html#set).
The second template function overloads `operator==`
to compare two objects of template class
[`multiset`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_set.html#multiset).
Both functions return
`left.size() == right.size() &&
equal(left.
begin(), left.
end(), right.begin())`.
## `operator<`
template
bool operator<(
const set & left,
const set & right);
template
bool operator<(
const multiset & left,
const multiset & right);Copy to clipboard
The first template function overloads `operator<`
to compare two objects of template class
[`set`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_set.html#set).
The second template function overloads `operator<`
to compare two objects of template class
[`multiset`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_set.html#multiset).
Both functions return
`lexicographical_compare(left.
begin(), left.
end(), right.begin(), right.end(),
left.value_comp())`.
## `operator<=`
template
bool operator<=(
const set & left,
const set & right);
template
bool operator<=(
const multiset & left,
const multiset & right);Copy to clipboard
The template function returns `!(right < left)`.
## `operator>`
template
bool operator>(
const set & left,
const set & right);
template
bool operator>(
const multiset & left,
const multiset & right);Copy to clipboard
The template function returns `right < left`.
## `operator>=`
template
bool operator>=(
const set & left,
const set & right);
template
bool operator>=(
const multiset & left,
const multiset & right);Copy to clipboard
The template function returns `!(left < right)`.
## `set`
* * *
**`allocator_type· begin· clear· const_iterator· const_pointer· const_reference· const_reverse_iterator· count· difference_type· empty· end· equal_range· erase· find· get_allocator· insert· iterator· key_comp· key_compare· key_type· lower_bound· max_size· pointer· rbegin· reference· rend· reverse_iterator· set· size· size_type· swap· upper_bound· value_comp· value_compare· value_type`**
* * *
template,
class Alloc = allocator >
class set {
public:
typedef Key key_type;
typedef Pr key_compare;
typedef Key value_type;
typedef Pr value_compare;
typedef Alloc allocator_type;
typedef Alloc::pointer pointer;
typedef Alloc::const_pointer const_pointer;
typedef Alloc::reference reference;
typedef Alloc::const_reference const_reference;
typedef T0 iterator;
typedef T1 const_iterator;
typedef T2 size_type;
typedef T3 difference_type;
typedef reverse_iterator
const_reverse_iterator;
typedef reverse_iterator reverse_iterator;
set();
explicit set(const Pr& pred);
set(const Pr& pred, const Alloc& al);
set(const set& right);
template
set(InIt first, InIt last);
template
set(InIt first, InIt last,
const Pr& pred);
template
set(InIt first, InIt last,
const Pr& pred, const Alloc& al);
iterator begin();
const_iterator begin() const;
iterator end();
const_iterator end() const;
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
reverse_iterator rend();
const_reverse_iterator rend() const;
size_type max_size() const;
bool empty() const;
Alloc get_allocator() const;
pair insert(const value_type& val);
iterator insert(iterator where, const value_type& val);
template
void insert(InIt first, InIt last);
iterator erase(iterator where);
iterator erase(iterator first, iterator last);
size_type erase(const Key& keyval);
void clear();
void swap(set& right);
key_compare key_comp() const;
value_compare value_comp() const;
iterator find(const Key& keyval);
const_iterator find(const Key& keyval) const;
size_type count(const Key& keyval) const;
iterator lower_bound(const Key& keyval);
const_iterator lower_bound(const Key& keyval) const;
iterator upper_bound(const Key& keyval);
const_iterator upper_bound(const Key& keyval) const;
pair equal_range(const Key& keyval);
pair
equal_range(const Key& keyval) const;
};Copy to clipboard
The template class describes an object that controls a
varying-length sequence of elements of type `const Key`.
The sequence is
[ordered by](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_stl.html#sequence%20ordering) the predicate
`Pr`.
Each element serves as both a **sort key** and a **value**.
The sequence is represented in a way that permits lookup, insertion,
and removal of an arbitrary element with a number of operations
proportional to the logarithm of the number of elements
in the sequence (logarithmic time). Moreover, inserting an element
invalidates no iterators, and removing an element
invalidates only those iterators which point at the removed element.
The object orders the sequence it controls by calling a
stored **function object** of type `Pr`. You access
this stored object by calling the member function
`key_comp()`.
Such a function object must impose a
[strict weak ordering](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_stl.html#strict%20weak%20ordering)
on sort keys of type `Key`.
For any element `X` that precedes
`Y` in the sequence,
`key_comp()(Y, X)` is false. (For the default function object
`less`,
sort keys never decrease in value.)
Unlike template class `multiset`,
an object of template class `set` ensures that
`key_comp()(X, Y)` is true.
(Each key is unique.)
The object allocates and frees storage for the sequence it controls
through a stored [allocator object](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_memory.html#allocator%20object)
of class `Alloc`. Such an allocator object must have
the same external interface as an object of template class
[`allocator`](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_memory.html#allocator).
Note that the stored allocator object is *not* copied when the container
object is assigned.
### `set::allocator_type`
typedef Alloc allocator_type;Copy to clipboard
The type is a synonym for the template parameter `Alloc`.
### `set::begin`
iterator begin();
const_iterator begin() const;Copy to clipboard
The member function returns a bidirectional iterator that points at
the first element of the sequence (or just beyond the end of an empty
sequence).
### `set::clear`
void clear();Copy to clipboard
The member function calls
`erase(
begin(),
end())`.
### `set::const_iterator`
typedef T1 const_iterator;Copy to clipboard
The type describes an object that can serve as a constant
bidirectional iterator for the controlled sequence.
It is described here as a
synonym for the implementation-defined type `T1`.
### `set::const_pointer`
typedef Alloc::const_pointer const_pointer;Copy to clipboard
The type describes an object that can serve as a constant pointer
to an element of the controlled sequence.
### `set::const_reference`
typedef Alloc::const_reference const_reference;Copy to clipboard
The type describes an object that can serve as a constant reference
to an element of the controlled sequence.
### `set::const_reverse_iterator`
typedef reverse_iterator
const_reverse_iterator;Copy to clipboard
The type describes an object that can serve as a constant reverse
bidirectional iterator for the controlled sequence.
### `set::count`
size_type count(const Key& keyval) const;Copy to clipboard
The member function returns the number of elements
in the range
`[lower_bound(keyval),
upper_bound(keyval)).`
### `set::difference_type`
typedef T3 difference_type;Copy to clipboard
The signed integer type describes an object that can represent the
difference between the addresses of any two elements in the controlled
sequence. It is described here as a
synonym for the implementation-defined type `T3`.
### `set::empty`
bool empty() const;Copy to clipboard
The member function returns true for an empty controlled sequence.
### `set::end`
iterator end();
const_iterator end() const;Copy to clipboard
The member function returns a bidirectional iterator that points
just beyond the end of the sequence.
### `set::equal_range`
pair
equal_range(const Key& keyval);
pair
equal_range(const Key& keyval) const;Copy to clipboard
The member function returns a pair of iterators `X`
such that `X.first ==
lower_bound(keyval)`
and `X.second ==
upper_bound(keyval)`.
### `set::erase`
iterator erase(iterator where);
iterator erase(iterator first, iterator last);
size_type erase(const Key& keyval);Copy to clipboard
The first member function removes the element of the controlled
sequence pointed to by `where`.
The second member function removes the elements
in the range `[first, last)`.
Both return an iterator that designates the first element remaining
beyond any elements removed, or
`end()` if no such element exists.
The third member removes
the elements with sort keys in the range
`[lower_bound(keyval),
upper_bound(keyval)).`
It returns the number of elements it removes.
The member functions never throw an exception.
In this
[implementation](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_index.html#implementation), the first two
member functions return an iterator that designates the first element remaining
beyond any elements removed, or
`end()` if no such element exists.
### `set::find`
iterator find(const Key& keyval);
const_iterator find(const Key& keyval) const;Copy to clipboard
The member function returns an iterator that designates
the element in the controlled sequence whose sort key has
[equivalent ordering](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_stl.html#equivalent%20ordering)
to `keyval`. If no such element exists,
the function returns
`end()`.
### `set::get_allocator`
Alloc get_allocator() const;Copy to clipboard
The member function returns the stored
[allocator object](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_memory.html#allocator%20object).
### `set::insert`
pair insert(const value_type& val);
iterator insert(iterator where, const value_type& val);
template
void insert(InIt first, InIt last);Copy to clipboard
The first member function determines whether an element `X`
exists in the sequence whose key has
[equivalent ordering](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_lib_stl.html#equivalent%20ordering)
to that of `val`. If not, it creates such
an element `X` and initializes it with `val`.
The function then determines the iterator `where` that
designates `X`. If an insertion occurred, the function
returns `pair(where, true)`.
Otherwise, it returns `pair(where, false)`.
The second member function returns `insert(val).first`,
using `where` as a starting place within the controlled
sequence to search for the insertion point. (Insertion can occur
in amortized constant time, instead of logarithmic time, if the
insertion point immediately precedes or follows `where`.)
The third member function
inserts the sequence of element values,
for each `where` in the range `[first, last)`,
by calling `insert(*where)`.
If an exception is thrown during the
insertion of a single element, the container is left unaltered
and the exception is rethrown.
If an exception is thrown during the
insertion of multiple elements, the container is left in a stable
but unspecified state and the exception is rethrown.
### `set::iterator`
typedef T0 iterator;Copy to clipboard
The type describes an object that can serve as a bidirectional
iterator for the controlled sequence.
It is described here as a
synonym for the implementation-defined type `T0`.
### `set::key_comp`
key_compare key_comp() const;Copy to clipboard
The member function returns the stored function object that
determines the order of elements in the controlled sequence.
The stored object defines the member function:
bool operator(const Key& left, const Key& right);Copy to clipboard
which returns true if `left` strictly
precedes `right` in the sort order.
### `set::key_compare`
typedef Pr key_compare;Copy to clipboard
The type describes a function object that can compare two
sort keys to determine the relative order of two
elements in the controlled sequence.
### `set::key_type`
typedef Key key_type;Copy to clipboard
The type describes the sort key object which constitutes each
element of the controlled sequence.
### `set::lower_bound`
iterator lower_bound(const Key& keyval);
const_iterator lower_bound(const Key& keyval) const;Copy to clipboard
The member function returns an iterator that designates the
earliest element `X` in the controlled sequence for which
`key_comp()(X, keyval)` is
false.
If no such element exists, the function returns
`end()`.
### `set::max_size`
size_type max_size() const;Copy to clipboard
The member function returns the length of the longest sequence that
the object can control.
### `set::pointer`
typedef Alloc::pointer pointer;Copy to clipboard
The type describes an object that can serve as a pointer to an
element of the controlled sequence.
### `set::rbegin`
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;Copy to clipboard
The member function returns a reverse bidirectional
iterator that points just
beyond the end of the controlled sequence. Hence, it designates the
beginning of the reverse sequence.
### `set::reference`
typedef Alloc::const_reference const_reference;Copy to clipboard
The type describes an object that can serve as a reference to an
element of the controlled sequence.
### `set::rend`
reverse_iterator rend();
const_reverse_iterator rend() const;Copy to clipboard
The member function returns a reverse bidirectional
iterator that points at the
first element of the sequence (or just beyond the end of an empty
sequence). Hence, it designates the end of the reverse sequence.
### `set::reverse_iterator`
typedef reverse_iterator reverse_iterator;Copy to clipboard
The type describes an object that can serve as a reverse
bidirectional iterator for the controlled sequence.
### `set::set`
set();
explicit set(const Pr& pred);
set(const Pr& pred, const Alloc& al);
set(const set& right);
template
set(InIt first, InIt last);
template
set(InIt first, InIt last,
const Pr& pred);
template
set(InIt first, InIt last,
const Pr& pred, const Alloc& al);Copy to clipboard
All constructors store an
[allocator object](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_memory.html#allocator%20object) and
initialize the controlled sequence. The allocator object is the argument
`al`, if present. For the copy constructor, it is
`right.get_allocator()`.
Otherwise, it is `Alloc()`.
All constructors also store a function object that can later
be returned by calling
`key_comp()`.
The function object is the argument `pred`, if present.
For the copy constructor, it is
`right.key_comp()`).
Otherwise, it is `Pr()`.
The first three constructors specify an
empty initial controlled sequence. The fourth constructor specifies
a copy of the sequence controlled by `right`.
The last three constructors specify the sequence of element values
`[first, last)`.
### `set::size`
size_type size() const;Copy to clipboard
The member function returns the length of the controlled sequence.
### `set::size_type`
typedef T2 size_type;Copy to clipboard
The unsigned integer type describes an object that can represent the
length of any controlled sequence. It is described here as a
synonym for the implementation-defined type `T2`.
### `set::swap`
void swap(set& right);Copy to clipboard
The member function swaps the controlled sequences between
`*this` and `right`. If
`get_allocator()
== right.get_allocator()`, it does so in constant time,
it throws an exception only as a result of copying the stored
function object of type `Pr`, and it invalidates no references, pointers,
or iterators that designate elements in the two controlled sequences.
Otherwise, it performs a number of element assignments and constructor calls
proportional to the number of elements in the two controlled sequences.
### `set::upper_bound`
iterator upper_bound(const Key& keyval)
const_iterator upper_bound(const Key& keyval) const;Copy to clipboard
The member function returns an iterator that designates the
earliest element `X` in the controlled sequence for which
`key_comp()(keyval, X)` is
true.
If no such element exists, the function returns
`end()`.
### `set::value_comp`
value_compare value_comp() const;Copy to clipboard
The member function returns a function object that
determines the order of elements in the controlled sequence.
### `set::value_compare`
typedef Pr value_compare;Copy to clipboard
The type describes a function object that can compare two
elements as sort keys to determine their relative order
in the controlled sequence.
### `set::value_type`
typedef Key value_type;Copy to clipboard
The type describes an element of the controlled sequence.
## `swap`
template
void swap(
multiset & left,
multiset & right);
template
void swap(
set & left,
set & right);Copy to clipboard
The template function executes
`left.swap(right)`.
* * *
See also the
**[Table of Contents](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_index.html#Table%20of%20Contents)** and the
**[Index](https://docs.qualcomm.com/doc/80-N3040-23/topic/_cpp_index.html)**.
*[Copyright](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_crit_pjp.html) © 1992-2006by P.J. Plauger. Portions derived from work[copyright](https://docs.qualcomm.com/doc/80-N3040-23/topic/cpp_crit_hp.html) © 1994by Hewlett-Packard Company. All rights reserved.*
Last Published: Oct 06, 2026
Previous Topic
Next Topic