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.popFront until either find!(pred)(choices, seq.front) is true, or seq becomes empty. Performs Ο(seq.length * choices.length) evaluations of pred.

For more information about pred see find.

Parameters

NameDescription
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.comparison.among.std

Example

int[] a = [ -1, 0, 1, 2, 3, 4, 5 ];
int[] b = [ 3, 1, 2 ];
writeln(findAmong(a, b)); // a[2 .. $]

Authors

Andrei Alexandrescu

License

Boost License 1.0.