std.algorithm.searching.canFind.canFind
- multiple declarations
Function canFind.canFind
Returns true
if and only if pred(e)
is true for any value e
in the
input range range
.
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, Needles...)
(
Range haystack,
scope Needles needles
)
if (Needles .length > 1 && 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 find
returns for the
same operation.