default (1) | template |
---|---|
custom (2) | template |
[first1,last1)
and [first2,last2)
.operator<
for the first version, and comp for the second. Two elements, a and b are considered equivalent if (!(a or if (!comp(a,b) && !comp(b,a))
.
The elements in the ranges shall already be ordered according to this same criterion (operator<
or comp). The resulting range is also sorted according to this.
The behavior of this function template is equivalent to:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
template <class InputIterator1, class InputIterator2, class OutputIterator>
OutputIterator set_intersection (InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2,
OutputIterator result)
{
while (first1!=last1 && first2!=last2)
{
if (*first1<*first2) ++first1;
else if (*first2<*first1) ++first2;
else {
*result = *first1;
++result; ++first1; ++first2;
}
}
return result;
}
[first1,last1)
, which contains all the elements between first1 and last1, including the element pointed by first1 but not the element pointed by last1.[first2,last2)
.bool
. The value returned indicates whether the first argument is considered to go before the second in the specific strict weak ordering it defines.
|
|
The intersection has 2 elements: 10 20 |
2*(count1+count2)-1
(where countX is the distance between firstX and lastX): Compares and assigns elements.[first1,last1)
and [first2,last2)
are accessed.