findAdj

Performs a linear scan of haystack from [0 .. haystack.length$(RP), returning the index of the first element that compares equal to the next element in the sequence. Comparisons will be performed using the supplied predicate or '==' if none is supplied.

  1. size_t findAdj(T[] haystack, Pred pred)
  2. size_t findAdj(Buffer!(T) haystack, Pred pred)
    size_t
    findAdj
    (,
    Pred pred = Pred.init
    )

Parameters

haystack Buffer!(T)

The array to scan.

pred Pred

The evaluation predicate, which should return true if e1 is equal to e2 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

auto buffer = createBuffer("abcddef");
test!("==")(findAdj(buffer), 3);
test!("==")(findAdj("abcddef"), 3);

Meta