|
| |
|
| Category: algorithms | | Component type: function |
template<class InputIterator, class EqualityComparable>
InputIterator find(InputIterator first, InputIterator last,
const EqualityComparable& value);
Returns the first iterator
i in the range
[first, last) such that
*i == value. Returns
last if no such iterator exists.
Defined in the standard header
algorithm, and in the nonstandard backward-compatibility header
algo.h.
-
EqualityComparable is a model of EqualityComparable.
-
InputIterator is a model of InputIterator.
-
Equality is defined between objects of type EqualityComparable and objects of InputIterator's value type.
-
[first, last) is a valid range.
Linear: at most
last - first comparisons for equality.
List<int> L;
L.push_back(3);
L.push_back(1);
L.push_back(7);
List<int>::iterator result = find(L.begin(), L.end(), 7);
assert(result == L.end() || *result == 7);
find_if.