STL Algorithms
STL provides a range of algorithms such as sort()
, find()
, and count()
.
#include <algorithm>
#include <vector>
vector<int> v = {5, 3, 1};
sort(v.begin(), v.end());
if (find(v.begin(), v.end(), 3) != v.end()) {
cout << "Found!";
}
STL algorithms work on iterators and are highly efficient.