diff --git a/minmax/doc/minmax_synopsis.html b/minmax/doc/minmax_synopsis.html index 7852994..1651a13 100644 --- a/minmax/doc/minmax_synopsis.html +++ b/minmax/doc/minmax_synopsis.html @@ -11,28 +11,32 @@
namespace boost { +#include <boost/tuple/tuple.hpp> - #include <boost/tuple/tuple.hpp> +namespace boost { template <class T> - std::tuple<T const&, T const&> > + tuple<T const&, T const&> > minmax(const T& a, const T& b); template <class T, class BinaryPredicate> - std::tuple<T const&, T const&> > + tuple<T const&, T const&> > minmax(const T& a, const T& b, BinaryPredicate comp); + +}-Synopsis of &boost/algorithm/minmax_element.hpp>
+Synopsis of <boost/algorithm/minmax_element.hpp> -namespace boost { +#include <utility> //for std::pair + +namespace boost { template <class ForwardIterator> std::pair<ForwardIterator,ForwardIterator> diff --git a/minmax/index.html b/minmax/index.html index 4bd605e..c2f2e45 100644 --- a/minmax/index.html +++ b/minmax/index.html @@ -36,10 +36,10 @@ HREF="../../../../boost/minmax.hpp">boost/algorithm/minmax.hpp>Motivation
-The minmax library is composed of two headers <boost/algorithm/minmax.hpp>. +
The minmax library is composed of two headers, <boost/algorithm/minmax.hpp> and <boost/algorithm/minmax_element.hpp>. +href="../../../boost/algorithm/minmax_element.hpp"><boost/algorithm/minmax_element.hpp>. (See rationale.) The problem solved by this library is that simultaneous min and max computation requires @@ -55,7 +55,7 @@ be enough. The present library solves both problems.
The first file implements the function templates minmax as straightforward extensions of the C++ -standard. As it returns a pair of const&, we must use the const&, we must use the Boost.tuple library to construct such pairs. (Please note: the intent is not to fix the known defaults of std::min @@ -85,25 +85,29 @@ comparisons and exactly n increments of the
+case. This implementation achieves three.-Synopsis of &boost/algorithm/minmax.hpp>
+Synopsis of <boost/algorithm/minmax.hpp> -namespace boost { +@@ -404,7 +408,7 @@ way to perform only three comparisons per pair and return the first min and first max elements. For a long time, it seemed any attempts at doing so would consume four comparisons per pair in the worst -case. This implementation achieves that.#include <boost/tuple/tuple.hpp> - #include <boost/tuple/tuple.hpp> +namespace boost { template <class T> - std::tuple<T const&, T const&> > + tuple<T const&, T const&> > minmax(const T& a, const T& b); template <class T, class BinaryPredicate> - std::tuple<T const&, T const&> > + tuple<T const&, T const&> > minmax(const T& a, const T& b, BinaryPredicate comp); + +}-Synopsis of &boost/algorithm/minmax_element.hpp>
+Synopsis of <boost/algorithm/minmax_element.hpp> -namespace boost { +#include <utility> // for std::pair + +namespace boost { template <class ForwardIterator> std::pair<ForwardIterator,ForwardIterator> @@ -276,7 +280,7 @@ the library underint main() { using namespace std; - boost::tupleresult1 = boost::minmax(1, 0); + boost::tuple<int const&, int const&> result1 = boost::minmax(1, 0); assert( result1.get<0>() == 0 ); assert( result1.get<1>() == 1 ); @@ -285,12 +289,12 @@ the library under generate_n(front_inserter(L), 1000, rand); typedef list<int>::const_iterator iterator; - pair< iterator, iterator > result = boost::minmax_element(L.begin(), L.end()); - cout << "The smallest element is " << *(result.first) << endl; - cout << "The largest element is " << *(result.second) << endl; + pair< iterator, iterator > result2 = boost::minmax_element(L.begin(), L.end()); + cout << "The smallest element is " << *(result2.first) << endl; + cout << "The largest element is " << *(result2.second) << endl; - assert( result.first == std::min_element(L.begin(), L.end()); - assert( result.second == std::max_element(L.begin(), L.end()); + assert( result2.first == std::min_element(L.begin(), L.end()); + assert( result2.second == std::max_element(L.begin(), L.end()); } It is not possible (or even desirable) to change the meaning of max_element, but it is still beneficial to provide a function called minmax_element, @@ -513,7 +517,7 @@ Comparable, nth_element .
-
Last modified 2002-07-01 +
Last modified 2004-07-01© Copyright Hervé Brönnimann, Polytechnic University, 2002--2004. Use, modification, and distribution is subject to the Boost Software