ddash.algorithm.pull

Removes elements from a range

Members

Functions

pull
ref pull(return ref Range range, Values values)

Removes elements from a range.

pullAt
auto pullAt(Range range, Indices indices)

Returns a range excluding the specified indices.

pullBy
ref pullBy(return ref Range range, Values values)

Removes elements from a range by a publicly visible field of ElemntType!Range

Examples

1 int[] arr = [1, 2, 3, 4, 5];
2 arr.pull(1, [2, 5]);
3 assert(arr == [3, 4]);
4 
5 import std.math: ceil;
6 double[] farr = [2.1, 1.2];
7 assert(farr.pull!ceil([2.3, 3.4]) == [1.2]);
8 
9 farr = [2.1, 1.2];
10 assert(farr.pull!((a, b) => ceil(a) == ceil(b))([2.3, 3.4]) == [1.2]);
11 
12 arr = [1, 2, 3, 4, 5];
13 assert(arr.pull!"a == b - 1"(4, 6) == [1, 2, 4]);
1 struct A {
2     int x;
3     int y;
4 }
5 
6 auto arr = [A(1, 2), A(3, 4), A(5, 6)];
7 assert(arr.pullBy!"y"(2, 6) == [A(3, 4)]);

Meta