ddash.algorithm.intersection

Creates a range of unique values that are included in all given ranges

Members

Functions

intersection
auto intersection(Range range, Rs values)

Creates a range of unique values that are included in all given ranges

Examples

1 assert([1, 2, 3].intersection([1], 3).equal([1, 3]));
2 
3 import std.math: ceil;
4 assert([2.1, 1.2].intersection!ceil([2.3, 3.4]).equal([2.1]));
5 assert([2.1, 1.2].intersection!((a, b) => ceil(a) == ceil(b))([2.3, 3.4]).equal([2.1]));
6 
7 struct A {
8     int value;
9 }
10 assert([A(1), A(2), A(3)].intersection!((a, b) => a.value == b.value)([A(2), A(3)]).equal([A(2), A(3)]));

Meta