std.algorithm.searching.canFind.canFind
- multiple declarations
Function canFind.canFind
Returns true
if and only if any value v
found in the
input range range
satisfies the predicate pred
.
Performs (at most) Ο(haystack
) evaluations of pred
.
bool canFind(Range)
(
Range haystack
)
if (is(typeof(find!pred(haystack))));
Function canFind.canFind
Returns true
if and only if needle
can be found in range
. Performs Ο(haystack
) evaluations of pred
.
bool canFind(Range, Element)
(
Range haystack,
scope Element needle
)
if (is(typeof(find!pred(haystack, needle))));
Function canFind.canFind
Returns the 1-based index of the first needle found in haystack
. If no
needle is found, then 0
is returned.
size_t canFind(Range, Ranges...)
(
Range haystack,
scope Ranges needles
)
if (Ranges .length > 1 && allSatisfy!(isForwardRange, Ranges) && is(typeof(find!pred(haystack, needles))));
So, if used directly in the condition of an if statement or loop, the result
will be true
if one of the needles is found and false
if none are
found, whereas if the result is used elsewhere, it can either be cast to
bool
for the same effect or used to get which needle was found first
without having to deal with the tuple that LREF find
returns for the
same operation.