The OpenD Programming Language

reversed

Reverses the direction of iteration for selected dimensions.

  1. auto reversed(Slice!(Iterator, N, kind) _slice)
    template reversed(Dimensions...)
    @trusted
    static if(allSatisfy!(isSize_t, Dimensions))
    reversed
    (
    Iterator
    size_t N
    SliceKind kind
    )
    (
    Slice!(Iterator, N, kind) _slice
    )
    if (
    Dimensions.length
    )
  2. Slice!(Iterator, N, Universal) reversed(Slice!(Iterator, N, kind) _slice, size_t[M] dimensions)
  3. auto reversed(Slice!(Iterator, N, kind) slice)

Members

Functions

reversed
auto reversed(Slice!(Iterator, N, kind) _slice)

Parameters

_slice

input slice

Dimensions

indices of dimensions to reverse order of iteration

Return Value

n-dimensional slice

Examples

import mir.ndslice.topology: iota;

auto slice = iota([2, 2], 1);
assert(slice                    == [[1, 2], [3, 4]]);

// Default
assert(slice.reversed           == [[3, 4], [1, 2]]);

// Template
assert(slice.reversed! 0        == [[3, 4], [1, 2]]);
assert(slice.reversed! 1        == [[2, 1], [4, 3]]);
assert(slice.reversed!(0, 1)    == [[4, 3], [2, 1]]);
assert(slice.reversed!(1, 0)    == [[4, 3], [2, 1]]);
assert(slice.reversed!(1, 1)    == [[1, 2], [3, 4]]);
assert(slice.reversed!(0, 0, 0) == [[3, 4], [1, 2]]);

// Function
assert(slice.reversed (0)       == [[3, 4], [1, 2]]);
assert(slice.reversed (1)       == [[2, 1], [4, 3]]);
assert(slice.reversed (0, 1)    == [[4, 3], [2, 1]]);
assert(slice.reversed (1, 0)    == [[4, 3], [2, 1]]);
assert(slice.reversed (1, 1)    == [[1, 2], [3, 4]]);
assert(slice.reversed (0, 0, 0) == [[3, 4], [1, 2]]);
import mir.ndslice.topology: iota, canonical;
auto slice = iota([2, 2], 1).canonical;
assert(slice                    == [[1, 2], [3, 4]]);

// Template
assert(slice.reversed! 0        == [[3, 4], [1, 2]]);
assert(slice.reversed!(0, 0, 0) == [[3, 4], [1, 2]]);

// Function
assert(slice.reversed (0)       == [[3, 4], [1, 2]]);
assert(slice.reversed (0, 0, 0) == [[3, 4], [1, 2]]);

Meta