Value | Meaning |
---|---|
shortest | Stop when the shortest range is exhausted |
longest | Stop when the longest range is exhausted |
requireSameLength | Require that all ranges are equal |
1 import std.algorithm.comparison : equal; 2 import std.exception : assertThrown; 3 import std.range.primitives; 4 import std.typecons : tuple; 5 6 auto a = [1, 2, 3]; 7 auto b = [4, 5, 6, 7]; 8 9 auto shortest = zip(StoppingPolicy.shortest, a, b); 10 assert(shortest.equal([ 11 tuple(1, 4), 12 tuple(2, 5), 13 tuple(3, 6) 14 ])); 15 16 auto longest = zip(StoppingPolicy.longest, a, b); 17 assert(longest.equal([ 18 tuple(1, 4), 19 tuple(2, 5), 20 tuple(3, 6), 21 tuple(0, 7) 22 ])); 23 24 auto same = zip(StoppingPolicy.requireSameLength, a, b); 25 same.popFrontN(3); 26 assertThrown!Exception(same.popFront);
Dictates how iteration in a zip and lockstep should stop. By default stop at the end of the shortest of all ranges.