3 ms·
Find probably wasn't the best example but even with find, I sometimes want to look for an item in a vector with 20 elements. In cases like that, I'm fine if fin
by mschuetz 10y ago
Find probably wasn't the best example but even with find, I sometimes want to look for an item in a vector with 20 elements. In cases like that, I'm fine if find() has to apply a comperator to every element until it finds the first that matches.
And functions like map (apply function to each element of a collection), filter (return new collection with all elements that match a condition) and possibly some others have to be applied to all elements in a collection anyway.
> Second, if you use a container as a part of your own class, defining a find() method is trivial.
It is, but I'd rather not have to define 20 trivial things when I start a new project.