find
Searches for the first element with the passed value
Definition
The find() algorithm is defined in the standard header <algorithm> and in the nonstandard backward-compatibility header <algo.h>.
Interface
#include<algorithm>
template <class InputIterator, class Type>
InputIterator find(
InputIterator first,
InputIterator last,
const Type& val
);Parameters:
| Parameter | Description |
| first | An input iterator addressing the position of the first element in the range to be searched for the specified value |
| last | An input iterator addressing the position one past the final element in the range to be searched for the specified value |
| val | The value to be searched for |
Description
Locates the position of the first occurrence of an element in a range that has a specified value.
The return value is an input iterator addressing the first occurrence of the specified value in the range being searched. If no such value exists in the range, the iterator returned addresses the last position of the range, one past the final element.
The operator== used to determine the match between an element and the specified value must impose an equivalence relation between its operands.
Complexity
At most, performs as many comparisons as the number of elements in the range [first,last).
CodeCogs®