reversed

Reverses the direction of iteration for selected dimensions.

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

Members

Aliases

reversed
alias reversed = .reversed!(staticMap!(toSize_t, Dimensions))
Undocumented in source.

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