ddash.algorithm.difference

Creates a range of values not included in the other given ranges.

Members

Functions

difference
auto difference(Range range, Rs values)

Creates a range of values not included in the other given ranges.

differenceBy
auto differenceBy(Range range, Rs values)

Same as difference except you can make it operatete on a publicly accessible member of ElementType!Range

Examples

1 import std.algorithm: map;
2 assert([1, 2, 3].difference([1], 3).equal([2]));
3 
4 import std.math: ceil;
5 assert([2.1, 2.4, 1.2, 2.9].difference!ceil([2.3, 0.1]).equal([1.2]));
6 assert([2.1, 2.4, 1.2, 2.9].difference!((a, b) => ceil(a) < ceil(b))([2.3, 3.4]).equal([1.2]));
7 
8 struct A {
9     int value;
10 }
11 
12 assert([A(1), A(2), A(3)].difference!((a, b) => a.value < b.value)([A(2), A(3)]).equal([A(1)]));

Meta