View source code
Display the source code in std/algorithm/searching.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Function std.algorithm.searching.findAmong
Searches the given range for an element that matches one of the given choices
.
Advances
by calling seq
seq.popFront
until
either
is find
!(pred)(choices
, seq.front)true
, or
becomes empty.
Performs Ο(seq
seq.length * choices.length
) evaluations of pred
.
Prototype
Range1 findAmong(alias pred, Range1, Range2)( Range1 seq, Range2 choices ) if (isInputRange!Range1 && isForwardRange!Range2);
Parameters
Name | Description |
---|---|
pred | The predicate to use for determining a match. |
seq | The input range to search. |
choices | A forward range
of possible choices . |
Returns
advanced to the first matching element, or seq
until
empty if there are no
matching elements.
See Also
Example
int[] a = [ -1, 0, 1, 2, 3, 4, 5 ]; int[] b = [ 3, 1, 2 ]; assert(findAmong(a, b) == a[2 .. $]);