rfindIf

Performs a linear scan of haystack from $(LP)haystack.length .. 0], returning the index of the first element where pred returns true.

  1. size_t rfindIf(T[] haystack, Pred pred)
    size_t
    rfindIf
    (
    T
    Pred
    )
    (
    in T[] haystack
    ,
    Pred pred
    )
  2. size_t rfindIf(Buffer!(T) haystack, Pred pred)

Parameters

haystack T[]

The array to search.

pred Pred

The evaluation predicate, which should return true if the element is a valid match and false if not. This predicate may be any callable type.

Return Value

Type: size_t

The index of the first match or haystack.length if no match was found.

Examples

test!("==")(rfindIf("bcecg", ( char c ) { return c == 'a'; }), 5);
auto buffer = createBuffer("bcecg");
test!("==")(rfindIf(buffer, ( char c ) { return c == 'a'; }), 5);

Meta