- Algorithm (C++)
In the
C++ programming language, algorithm is a function template that can work with (theoretically) any container containing values of any type. However, this is not always true because algorithms may have restrictions on the container/iterator category or even have requirements on the value type.The C++ standard provides some standard algorithms collected in the
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 arguments
*ForwardIterator max_element(ForwardIterator begin, ForwardIterator end)
finds the maximum element of a range
*T min(T a, T b)
returns the smaller of the two arguments
*ForwardIterator min_element(ForwardIterator begin, ForwardIterator end)
finds the minimum element of a rangeUsage
External links
* [http://wwwasd.web.cern.ch/wwwasd/lhc++/RW/stdlibcr/classref.htm Standard C++ 1.2 Class Reference]
Wikimedia Foundation. 2010.