The OpenD Programming Language

ZipIterator

Iterates multiple iterators in lockstep.

ZipIterator is used by zip.

Members

Functions

assumeFieldsHaveZeroShift
auto assumeFieldsHaveZeroShift()

Defined if at least one of Iterators has member assumeFieldsHaveZeroShift.

lightConst
auto lightConst()
lightImmutable
auto lightImmutable()

Variables

_iterators
Iterators _iterators;

Examples

import mir.ndslice.traits: isIterator;

double[10] data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
alias ItA = IotaIterator!int;
alias ItB = double*;
alias ItZ = ZipIterator!(ItA, ItB);
auto zip = ItZ(ItA(3), data.ptr);
assert((*zip).a == 3);
assert((*zip).b == 1);

// iteration
++zip;
assert((*zip).a == 3 + 1);
assert((*zip).b == 1 + 1);
assert(&(*zip).b() == data.ptr + 1);

assert(zip[4].a == 3 + 5);
assert(zip[4].b == 1 + 5);
assert(&zip[4].b() == data.ptr + 5);

--zip;
assert((*zip).a == 3);
assert((*zip).b == 1);

assert((*(zip + 2)).a == 3 + 2);
assert((*(zip - 3)).a == 3 + -3);
assert((*(zip + 2)).b == 1 + 2);
assert((*(zip + 3 - 3)).b == 1);
assert((zip - 3).opBinary!"-"(zip) == -3);

assert(zip == zip);
assert(zip - 1 < zip);

static assert(isIterator!(ZipIterator!(double*, int*)));
static assert(isIterator!(ZipIterator!(immutable(double)*, immutable(int)*)));

Meta