D
Draw
Hi All,
Just a thought, about the find() algorithm in the C++ STL. I read that
the find algorithm can take a range of iterators. If it does not find
the element it is looking for in that range it returns the iterator to
the last element in the range, not to the last element in the
container, to the last element in the range. That being said, how can
we tell if find() has been successful in finding the element we need?
Its easy when we are searching the whole container, we can always the
container's end() method, but when we are searching only a subset of
all the elements in a container, what then? Do we have a better way
than checking the element that find returns again?(sounds inefficient,
repetitive).
Would appreciate your thoughts on this matter.
Thanks, Draw
Just a thought, about the find() algorithm in the C++ STL. I read that
the find algorithm can take a range of iterators. If it does not find
the element it is looking for in that range it returns the iterator to
the last element in the range, not to the last element in the
container, to the last element in the range. That being said, how can
we tell if find() has been successful in finding the element we need?
Its easy when we are searching the whole container, we can always the
container's end() method, but when we are searching only a subset of
all the elements in a container, what then? Do we have a better way
than checking the element that find returns again?(sounds inefficient,
repetitive).
Would appreciate your thoughts on this matter.
Thanks, Draw