Różnice między wybraną wersją a wersją aktualną.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
min_element_max_element [2008/12/11 00:14] kkukolow |
min_element_max_element [2008/12/11 00:16] kkukolow |
||
---|---|---|---|
Linia 36: | Linia 36: | ||
<code cpp> | <code cpp> | ||
template <class ForwardIterator> | template <class ForwardIterator> | ||
- | ForwardIterator max_element ( ForwardIterator first, ForwardIterator last ) | + | ForwardIterator min_element ( ForwardIterator first, ForwardIterator last ) |
{ | { | ||
- | ForwardIterator largest = first; | + | ForwardIterator lowest= first; |
if (first==last) return last; | if (first==last) return last; | ||
while (++first!=last) | while (++first!=last) | ||
- | if (*largest<*first) // or: if (comp(*largest,*lowest)) for the comp version | + | if (*first<*lowest) // or: if (comp(*lowest,*first)) for the comp version |
- | largest=first; | + | lowest=first; |
- | return largest; | + | return lowest; |
} | } | ||
</code> | </code> |