findIndex

Finds an index such that pred(slices[0][index], ..., slices[$-1][index]) is true.

  1. Select!(DimensionCount!(Slices[0]) > 1, size_t[DimensionCount!(Slices[0])], size_t) findIndex(Slices slices)
    template findIndex(alias pred)
    @optmath
    static if(__traits(isSame, naryFun!pred, pred))
    @optmath
    Select!(DimensionCount!(Slices[0]) > 1, size_t[DimensionCount!(Slices[0])], size_t)
    findIndex
    (
    Slices...
    )
    (
    Slices slices
    )
    if (
    Slices.length
    )
  2. alias findIndex = .findIndex!(naryFun!pred)

Members

Aliases

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

Functions

findIndex
Select!(DimensionCount!(Slices[0]) > 1, size_t[DimensionCount!(Slices[0])], size_t) findIndex(Slices slices)

Parameters

pred

A predicate.

Examples

Ranges and arrays

import std.range : iota;
// 0 1 2 3 4 5
auto sl = iota(5);
size_t index = sl.findIndex!"a == 3";

assert(index == 3);
assert(sl[index] == 3);

assert(sl.findIndex!(a => a == 8) == size_t.max);
import mir.ndslice.topology : iota;
// 0 1 2
// 3 4 5
auto sl = iota(2, 3);
size_t[2] index = sl.findIndex!(a => a == 3);

assert(sl[index] == 3);

index = sl.findIndex!"a == 6";
assert(index[0] == size_t.max);
assert(index[1] == size_t.max);

See Also

find, any. Optimization: findIndex!"a" has accelerated specialization for slices created with mir.ndslice.topology.bitwise, mir.ndslice.allocation.bitSlice.

Meta