This section defines all the basic set operations on sorted structures
. They also work with
multisets (
[multiset])
containing multiple copies of equivalent elements
. The semantics of the set operations are generalized to
multisets
in a standard way by defining
set_union()
to contain the maximum number of occurrences of every element,
set_intersection()
to contain the minimum, and so on
.template<class InputIterator1, class InputIterator2>
bool includes(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2>
bool includes(ExecutionPolicy&& exec,
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2);
template<class InputIterator1, class InputIterator2, class Compare>
bool includes(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
Compare comp);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2, class Compare>
bool includes(ExecutionPolicy&& exec,
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
Compare comp);
Returns:
true
if
[first2, last2) is empty or
if every element in the range
[first2, last2)
is contained in the range
[first1, last1). Complexity:
At most
2 * ((last1 - first1) + (last2 - first2)) - 1
comparisons
. template<class InputIterator1, class InputIterator2,
class OutputIterator>
OutputIterator
set_union(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
OutputIterator result);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class ForwardIterator>
ForwardIterator
set_union(ExecutionPolicy&& exec,
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
ForwardIterator result);
template<class InputIterator1, class InputIterator2,
class OutputIterator, class Compare>
OutputIterator
set_union(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
OutputIterator result, Compare comp);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class ForwardIterator, class Compare>
ForwardIterator
set_union(ExecutionPolicy&& exec,
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
ForwardIterator result, Compare comp);
Requires:
The resulting range shall not overlap with either of the original ranges
. Effects:
Constructs a sorted union of the elements from the two ranges;
that is, the set of elements that are present in one or both of the ranges
. Returns:
The end of the constructed range
. Complexity:
At most
2 * ((last1 - first1) + (last2 - first2)) - 1
comparisons
. Remarks: If
[first1, last1) contains
m elements that are equivalent to
each other and
[first2, last2) contains
n elements that are equivalent
to them, then all
m elements from the first range shall be copied to the output
range, in order, and then elements from the second range shall
be copied to the output range, in order
. template<class InputIterator1, class InputIterator2,
class OutputIterator>
OutputIterator
set_intersection(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
OutputIterator result);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class ForwardIterator>
ForwardIterator
set_intersection(ExecutionPolicy&& exec,
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
ForwardIterator result);
template<class InputIterator1, class InputIterator2,
class OutputIterator, class Compare>
OutputIterator
set_intersection(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
OutputIterator result, Compare comp);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class ForwardIterator, class Compare>
ForwardIterator
set_intersection(ExecutionPolicy&& exec,
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
ForwardIterator result, Compare comp);
Requires:
The resulting range shall not overlap with either of the original ranges
. Effects:
Constructs a sorted intersection of the elements from the two ranges;
that is, the set of elements that are present in both of the ranges
. Returns:
The end of the constructed range
. Complexity:
At most
2 * ((last1 - first1) + (last2 - first2)) - 1
comparisons
. Remarks: If
[first1, last1) contains
m elements that are equivalent to
each other and
[first2, last2) contains
n elements that are equivalent
to them, the first elements shall be copied from the first range
to the output range, in order
. template<class InputIterator1, class InputIterator2,
class OutputIterator>
OutputIterator
set_difference(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
OutputIterator result);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class ForwardIterator>
ForwardIterator
set_difference(ExecutionPolicy&& exec,
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
ForwardIterator result);
template<class InputIterator1, class InputIterator2,
class OutputIterator, class Compare>
OutputIterator
set_difference(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
OutputIterator result, Compare comp);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class ForwardIterator, class Compare>
ForwardIterator
set_difference(ExecutionPolicy&& exec,
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
ForwardIterator result, Compare comp);
Requires:
The resulting range shall not overlap with either of the original ranges
. Effects:
Copies the elements of the range
[first1, last1)
which are not present in the range
[first2, last2)
to the range beginning at
result. The elements in the constructed range are sorted
.Returns:
The end of the constructed range
. Complexity:
At most
2 * ((last1 - first1) + (last2 - first2)) - 1
comparisons
. Remarks:
If
[first1, last1)
contains
m
elements that are equivalent to each other and
[first2, last2)
contains
n
elements that are equivalent to them, the last
elements from
[first1, last1)
shall be copied to the output range
. template<class InputIterator1, class InputIterator2,
class OutputIterator>
OutputIterator
set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
OutputIterator result);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class ForwardIterator>
ForwardIterator
set_symmetric_difference(ExecutionPolicy&& exec,
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
ForwardIterator result);
template<class InputIterator1, class InputIterator2,
class OutputIterator, class Compare>
OutputIterator
set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
OutputIterator result, Compare comp);
template<class ExecutionPolicy, class ForwardIterator1, class ForwardIterator2,
class ForwardIterator, class Compare>
ForwardIterator
set_symmetric_difference(ExecutionPolicy&& exec,
ForwardIterator1 first1, ForwardIterator1 last1,
ForwardIterator2 first2, ForwardIterator2 last2,
ForwardIterator result, Compare comp);
Requires:
The resulting range shall not overlap with either of the original ranges
. Effects:
Copies the elements of the range
[first1, last1)
that are not present in the range
[first2, last2),
and the elements of the range
[first2, last2)
that are not present in the range
[first1, last1)
to the range beginning at
result. The elements in the constructed range are sorted
.Returns:
The end of the constructed range
. Complexity:
At most
2 * ((last1 - first1) + (last2 - first2)) - 1
comparisons
. Remarks:
If
[first1, last1) contains
m elements that are equivalent to each other and
[first2, last2) contains
n elements that are equivalent to them, then
of those elements shall be copied to the output range: the last
of these elements from
[first1, last1) if , and the last
of these elements from
[first2, last2) if
.