Algorithm (C++)
Appearance
C++ Standard Library |
---|
Containers |
C standard library |
In the C++ programming language, algorithms are components that perform algorithmic operations on containers and other sequences.[1]
The C++ standard provides some standard algorithms collected in the <algorithm> standard header. All algorithms are in the std
namespace.
A few of the most commonly used algorithms are:
void copy(ForwardIterator source_begin, ForwardIterator source_end, ForwardIterator destination_begin)
void fill(ForwardIterator destination_begin, ForwardIterator destination_end, T value)
ForwardIterator find(ForwardIterator begin, ForwardIterator end, T search_object)
(returns an iterator the found object orend
if the object isn't found)T max(T a, T b)
returns the greater of the two argumentsForwardIterator max_element(ForwardIterator begin, ForwardIterator end)
finds the maximum element of a rangeT min(T a, T b)
returns the smaller of the two argumentsForwardIterator min_element(ForwardIterator begin, ForwardIterator end)
finds the minimum element of a range
References
- ^ ISO/IEC (2003). ISO/IEC 14882:2003(E): Programming Languages - C++ §25 Algorithms library [lib.algorithms] para. 1