AlgoPlus
v0.1.0
Loading...
Searching...
No Matches
src
algorithms
searching
linear_search.h
1
#ifndef LINEAR_SEARCH_H
2
#define LINEAR_SEARCH_H
3
4
#ifdef __cplusplus
5
#include <iostream>
6
#include <vector>
7
#endif
8
16
template
<
typename
T>
bool
linear_search(std::vector<T> arr, T key) {
17
return
std::find_if(arr.begin(), arr.end(), [key](
const
auto
& x) { return x == key; }) !=
18
arr.end();
19
}
20
21
#endif
Generated by
1.13.2