minPos

Finds a backward index such that slice.backward(index) is minimal(maximal).

  1. Slice!(Iterator, N, kind == Contiguous && N > 1 ? Canonical : kind) minPos(Slice!(Iterator, N, kind) slice)
    template minPos(alias pred = "a < b")
    @optmath
    static if(__traits(isSame, naryFun!pred, pred))
    @optmath
    Slice!(Iterator, N,
    kind == Contiguous &&
    N > 1
    ? Canonical : kind)
    minPos
    (
    Iterator
    size_t N
    SliceKind kind
    )
    (
    Slice!(Iterator, N, kind) slice
    )
  2. alias minPos = .minPos!(naryFun!pred)

Members

Aliases

minPos
alias minPos = .minPos!(naryFun!pred)
Undocumented in source.

Functions

minPos
Slice!(Iterator, N, kind == Contiguous && N > 1 ? Canonical : kind) minPos(Slice!(Iterator, N, kind) slice)

Parameters

pred

A predicate.

Examples

import mir.ndslice.slice: sliced;
auto s = [
    2, 6, 4, -3,
    0, -4, -3, 3,
    -3, -2, 7, 2,
    ].sliced(3, 4);

auto pos = s.minPos;

assert(pos == s[$ - 2 .. $, $ - 3 .. $]);
assert(pos.first == -4);
assert(s.backward(pos.shape) == -4);

pos = s.maxPos;

assert(pos == s[$ - 1 .. $, $ - 2 .. $]);
assert(pos.first == 7);
assert(s.backward(pos.shape) == 7);

See Also

Meta