template<class InIt1, class InIt2, class OutIt>
OutIt set_union(InIt1 first1, InIt1 last1,
InIt2 first2, InIt2 last2, OutIt x);
template<class InIt1, class InIt2, class OutIt, class Pred>
OutIt set_union(InIt1 first1, InIt1 last1,
InIt2 first2, InIt2 last2, OutIt x, Pred pr);
The first template function alternately copies values from two sequences designated by iterators in the ranges [first1,
last1)
and [first2, last2)
, both ordered by operator<
, to form a merged sequence of length K
beginning at x
,
also ordered by operator<
. The function then returns x + K
.
The merge occurs without altering the relative order of elements within either sequence. Moreover, for two elements
from different sequences that have equivalent ordering that would otherwise be copied to adjacent elements, the
function copies only the element from the ordered range [first1, last1)
and skips the other. Thus, the function
merges two ordered sequences to form another ordered sequence that is effectively the union of two sets.
If x
and first1
designate regions of storage, the range [x, x + K)
must not overlap the range [first1, last1)
.
If x
and first2
designate regions of storage, the range [x, x + K)
must not overlap the range [first2, last2)
.
The function evaluates the ordering predicate X < Y
at most 2 * ((last1 - first1) + (last2 - first2)) -
1
times.
The second template function behaves the same, except that it replaces operator<(X, Y)
with pr(X, Y)
.