The OpenD Programming Language

StairsIterator

StairsIterator is used by stairs.

Members

Functions

lightConst
auto lightConst()
lightImmutable
auto lightImmutable()
opIndex
Slice!Iterator opIndex(ptrdiff_t index)
opUnary
Slice!Iterator opUnary()

Variables

_iterator
Iterator _iterator;
_length
size_t _length;

Examples

// 0
// 1 2
// 3 4 5
// 6 7 8 9
// 10 11 12 13 14
auto it = StairsIterator!(IotaIterator!size_t, "+")(1, IotaIterator!size_t());
assert(*it == [0]);
assert(it[4] == [10, 11, 12, 13, 14]);
assert(*(it + 4) == [10, 11, 12, 13, 14]);
++it;
assert(*it == [1, 2]);
it += 3;
assert(*it == [10, 11, 12, 13, 14]);
assert(it[-3] == [1, 2]);
assert(*(it - 3) == [1, 2]);
assert(it + 1 > it);
assert(it + 1 - 1 == it);
assert(it - 3 - it == -3);
--it;
assert(*it == [6, 7, 8, 9]);
// [0, 1, 2, 3, 4],
//    [5, 6, 7, 8],
//     [9, 10, 11],
//        [12, 13],
//            [14]]);

auto it = StairsIterator!(IotaIterator!size_t, "-")(5, IotaIterator!size_t());
assert(*it == [0, 1, 2, 3, 4]);
assert(it[4] == [14]);
assert(*(it + 4) == [14]);
++it;
assert(*it == [5, 6, 7, 8]);
it += 3;
assert(*it == [14]);
assert(it[-3] == [5, 6, 7, 8]);
assert(*(it - 3) == [5, 6, 7, 8]);
assert(it + 1 > it);
assert(it + 1 - 1 == it);
assert(it - 3 - it == -3);
--it;
assert(*it == [12, 13]);

Meta