View source code
Display the source code in std/algorithm/searching.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
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.
Function std.algorithm.searching.findAmong
Searches the given range for an element that matches one of the given choices.
InputRange findAmong(alias pred, InputRange, ForwardRange)
(
InputRange seq,
ForwardRange choices
)
if (isInputRange!InputRange && isForwardRange!ForwardRange);
Advances seq
by calling seq
until either
find!(pred)(choices, seq
is true
, or seq
becomes empty.
Performs Ο(seq
) evaluations of pred
.
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
seq
advanced to the first matching element, or until empty if there are no
matching elements.
See Also
find
, algorithm
Example
int[] a = [ -1, 0, 1, 2, 3, 4, 5 ];
int[] b = [ 3, 1, 2 ];
writeln(findAmong(a, b)); // a[2 .. $]
Authors
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.