Brian Silverman | 598d029 | 2018-08-04 23:56:47 -0700 | [diff] [blame^] | 1 | [/ |
| 2 | Copyright 2010 Neil Groves |
| 3 | Distributed under the Boost Software License, Version 1.0. |
| 4 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 5 | /] |
| 6 | [section:max_element max_element] |
| 7 | |
| 8 | [heading Prototype] |
| 9 | |
| 10 | `` |
| 11 | template<class ForwardRange> |
| 12 | typename range_iterator<ForwardRange>::type |
| 13 | max_element(ForwardRange& rng); |
| 14 | |
| 15 | template<class ForwardRange> |
| 16 | typename range_iterator<const ForwardRange>::type |
| 17 | max_element(const ForwardRange& rng); |
| 18 | |
| 19 | template<class ForwardRange, class BinaryPredicate> |
| 20 | typename range_iterator<ForwardRange>::type |
| 21 | max_element(ForwardRange& rng, BinaryPredicate pred); |
| 22 | |
| 23 | template<class ForwardRange, class BinaryPredicate> |
| 24 | typename range_iterator<const ForwardRange>::type |
| 25 | max_element(const ForwardRange& rng, BinaryPredicate pred); |
| 26 | |
| 27 | |
| 28 | template< |
| 29 | range_return_value re, |
| 30 | class ForwardRange |
| 31 | > |
| 32 | typename range_return<ForwardRange, re>::type |
| 33 | max_element(ForwardRange& rng); |
| 34 | |
| 35 | template< |
| 36 | range_return_value_re, |
| 37 | class ForwardRange |
| 38 | > |
| 39 | typename range_return<const ForwardRange, re>::type |
| 40 | max_element(const ForwardRange& rng); |
| 41 | |
| 42 | template< |
| 43 | range_return_value re, |
| 44 | class ForwardRange, |
| 45 | class BinaryPredicate |
| 46 | > |
| 47 | typename range_return<ForwardRange, re>::type |
| 48 | max_element(ForwardRange& rng, BinaryPredicate pred); |
| 49 | |
| 50 | template< |
| 51 | range_return_value re, |
| 52 | class ForwardRange, |
| 53 | class BinaryPredicate |
| 54 | > |
| 55 | typename range_return<const ForwardRange, re>::type |
| 56 | max_element(const ForwardRange& rng, BinaryPredicate pred); |
| 57 | `` |
| 58 | |
| 59 | [heading Description] |
| 60 | |
| 61 | The versions of `max_element` that return an iterator, return the iterator to the maximum value as determined by using `operator<` if a predicate is not supplied. Otherwise the predicate `pred` is used to determine the maximum value. The versions of `max_element` that return a `range_return`, defines `found` in the same manner as the returned iterator described above. |
| 62 | |
| 63 | [heading Definition] |
| 64 | |
| 65 | Defined in the header file `boost/range/algorithm/max_element.hpp` |
| 66 | |
| 67 | [heading Requirements] |
| 68 | |
| 69 | [*For the non-predicate versions:] |
| 70 | |
| 71 | * `ForwardRange` is a model of the __forward_range__ Concept. |
| 72 | * `ForwardRange`'s value type is a model of the `LessThanComparableConcept`. |
| 73 | |
| 74 | [*For the predicate versions:] |
| 75 | |
| 76 | * `ForwardRange` is a model of the __forward_range__ Concept. |
| 77 | * `BinaryPredicate` is a model of the `BinaryPredicateConcept`. |
| 78 | * `ForwardRange`'s value type is convertible to both of `BinaryPredicate`'s argument types. |
| 79 | |
| 80 | [heading Complexity] |
| 81 | |
| 82 | Linear. Zero comparisons if `empty(rng)`, otherwise `distance(rng) - 1` comparisons. |
| 83 | |
| 84 | [endsect] |
| 85 | |
| 86 | |