what\'s the alternative?
Should I write by myself?
what's the alternative?
The standard offers std::find, for sequential search over arbitrary sequences of like-elements (or something like that).
This can be applied to all containers supporting iterators, but for internally sorted containers (like std::map
) the search can be optimized. In that case, the container offers it's own find
member function.
why there is no find for vector in C++?
There was no point in creating a std::vector??>::find
as the implementation would be identical to std::find(vector.begin(), vector.end(), value_to_find);
.
Should I write by myself?
No. Unless you have specific limitations or requirements, you should use the STL implementation whenever possible.