Performs a linear search for a value in a range.
Declared in <absl/algorithm/algorithm.h>
template<
typename InputIterator,
typename EqualityComparable>
constexpr
bool
linear_search(
InputIterator first,
InputIterator last,
EqualityComparable const& value);
Searches the range [first, last)] and returns true if it contains an element equal to value.
A linear search is of O(n) complexity and makes at most n = (last - first) comparisons. A linear search over short containers may be faster than a binary search, even when the container is sorted.
true if [first, last)] contains an element equal to value.
| Name | Description |
|---|---|
| first | Iterator to the first element of the range to search. |
| last | Iterator one past the last element of the range to search. |
| value | The value to search for. |