std.algorithm.setops.set_symmetric_difference
- multiple declarations
- Function setSymmetricDifference
- Struct SetSymmetricDifference
Function setSymmetricDifference
Lazily computes the symmetric difference of
and r1
,
i.e. the elements that are present in exactly one of r2
and r1
. The two ranges are assumed to be sorted by r2
less
, and the
output is also sorted by less
. The element types of the two
ranges must have a common type.
If both arguments are ranges of L-values of the same type then
will also be a range of L-values of
that type.
SetSymmetricDifference
Prototype
SetSymmetricDifference!(less,R1,R2) setSymmetricDifference(alias less, R1, R2)( R1 r1, R2 r2 );
Parameters
Name | Description |
---|---|
less | Predicate the given ranges are sorted by. |
r1 | The first range. |
r2 | The second range. |
Returns
See also
Example
import std.algorithm.comparison : equal; int[] a = [ 1, 2, 4, 5, 7, 9 ]; int[] b = [ 0, 1, 2, 4, 7, 8 ]; assert(equal(setSymmetricDifference(a, b), [0, 5, 8, 9][])); static assert(isForwardRange!(typeof(setSymmetricDifference(a, b))));
Struct SetSymmetricDifference
Lazily computes the symmetric difference of r1
and r2
,
i.e. the elements that are present in exactly one of r1
and r2
. The two ranges are assumed to be sorted by less
, and the
output is also sorted by less
. The element types of the two
ranges must have a common type.
If both arguments are ranges of L-values of the same type then
will also be a range of L-values of
that type.
SetSymmetricDifference
Parameters
Name | Description |
---|---|
less | Predicate the given ranges are sorted by. |
r1 | The first range. |
r2 | The second range. |
Returns
A range of the symmetric difference between r1
and r2
.
See also
Example
import std.algorithm.comparison : equal; int[] a = [ 1, 2, 4, 5, 7, 9 ]; int[] b = [ 0, 1, 2, 4, 7, 8 ]; assert(equal(setSymmetricDifference(a, b), [0, 5, 8, 9][])); static assert(isForwardRange!(typeof(setSymmetricDifference(a, b))));