Bug 5226 – indexOf() which takes a pred but no needle

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2010-11-16T16:22:00Z
Last change time
2015-06-09T05:15:06Z
Assigned to
andrei
Creator
issues.dlang

Comments

Comment #0 by issues.dlang — 2010-11-16T16:22:17Z
Currently, std.algorithm has an indexOf() function which takes an optional predicate (as a template parameter), a range, and a needle. I think that we should have a version that takes the predicate and a range but no needle, using only the predicate to find the index that you're looking for. In many ways, indexOf() is indentical to find() in terms of what it's for except that find() returns the remainder of the range and indexOf() returns where in the range what you're trying to find is, so indexOf()'s flexibility should be closer to find()'s (except insomuch as differences in the range types that they take affect them). In any case, a version of indexOf() which takes no needle but just the predicate and the range would be a very useful addition to Phobos.
Comment #1 by andrei — 2013-03-09T19:16:46Z
Now countUntil took over that role.