From 2b6c0fdd91b52fe05db21bbaeb5a941344596c1c Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Fri, 6 Jul 2001 08:53:41 +0000 Subject: [PATCH] Added Compare parameter to Min/Max. --- .../doc_tex/NumberTypeSupport/Numbertype.tex | 10 +++++----- .../support/NumberTypeSupport/Numbertype.tex | 10 +++++----- .../include/CGAL/number_utils_classes.h | 16 ++++++++++++---- Packages/Number_types/version | 2 +- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Packages/Number_types/doc_tex/NumberTypeSupport/Numbertype.tex b/Packages/Number_types/doc_tex/NumberTypeSupport/Numbertype.tex index c350158aa89..80638034569 100644 --- a/Packages/Number_types/doc_tex/NumberTypeSupport/Numbertype.tex +++ b/Packages/Number_types/doc_tex/NumberTypeSupport/Numbertype.tex @@ -58,15 +58,15 @@ In fact \ccc{double} and \ccc{float} also fulfill the requirements. \ccCreationVariable{ntvar} \ccConstructor{NT();} - {Declaration of a variable.} + {Declaration of a variable.} \ccConstructor{NT(const NT &ntval);} - {Declaration and initialization.} + {Declaration and initialization.} \ccConstructor{NT(i)} - {Declaration and initialization with a small integer + {Declaration and initialization with a small integer constant $i$, $0 \leq i \leq 127$. The neutral elements for addition (zero) and multiplication (one) are needed quite often, but sometimes other small constants are useful too. The value 127 was chosen such @@ -225,8 +225,8 @@ named \ccc{Sgn} in order to avoid a conflict with the type \ccInclude{CGAL/number_utils_classes.h} -\ccc{class Min;}\\ -\ccc{class Max;}\\ +\ccc{class Min;}\\ +\ccc{class Max;}\\ \ccc{class Abs;}\\ \ccc{class Sgn;}\\ \ccc{class Is_negative;}\\ diff --git a/Packages/Number_types/doc_tex/support/NumberTypeSupport/Numbertype.tex b/Packages/Number_types/doc_tex/support/NumberTypeSupport/Numbertype.tex index c350158aa89..80638034569 100644 --- a/Packages/Number_types/doc_tex/support/NumberTypeSupport/Numbertype.tex +++ b/Packages/Number_types/doc_tex/support/NumberTypeSupport/Numbertype.tex @@ -58,15 +58,15 @@ In fact \ccc{double} and \ccc{float} also fulfill the requirements. \ccCreationVariable{ntvar} \ccConstructor{NT();} - {Declaration of a variable.} + {Declaration of a variable.} \ccConstructor{NT(const NT &ntval);} - {Declaration and initialization.} + {Declaration and initialization.} \ccConstructor{NT(i)} - {Declaration and initialization with a small integer + {Declaration and initialization with a small integer constant $i$, $0 \leq i \leq 127$. The neutral elements for addition (zero) and multiplication (one) are needed quite often, but sometimes other small constants are useful too. The value 127 was chosen such @@ -225,8 +225,8 @@ named \ccc{Sgn} in order to avoid a conflict with the type \ccInclude{CGAL/number_utils_classes.h} -\ccc{class Min;}\\ -\ccc{class Max;}\\ +\ccc{class Min;}\\ +\ccc{class Max;}\\ \ccc{class Abs;}\\ \ccc{class Sgn;}\\ \ccc{class Is_negative;}\\ diff --git a/Packages/Number_types/include/CGAL/number_utils_classes.h b/Packages/Number_types/include/CGAL/number_utils_classes.h index 6f3bb6fff1d..da8bfd82b70 100644 --- a/Packages/Number_types/include/CGAL/number_utils_classes.h +++ b/Packages/Number_types/include/CGAL/number_utils_classes.h @@ -88,18 +88,26 @@ struct Abs :public CGAL_STD::unary_function< NT, NT > { { return abs( x); } }; -template < class NT > +template < class NT, class Compare = std::less< NT > > struct Min :public CGAL_STD::binary_function< NT, NT, NT > { typedef Arity_tag< 2 > Arity; + Min() {} + Min(const Compare& c_) : c(c_) {} NT operator()( const NT& x, const NT& y) const - { return std::min( x, y); } + { return std::min( x, y, c); } +protected: + Compare c; }; -template < class NT > +template < class NT, class Compare = std::less< NT > > struct Max :public CGAL_STD::binary_function< NT, NT, NT > { typedef Arity_tag< 2 > Arity; + Max() {} + Max(const Compare& c_) : c(c_) {} NT operator()( const NT& x, const NT& y) const - { return std::max( x, y); } + { return std::max( x, y, c); } +protected: + Compare c; }; template < class NT > diff --git a/Packages/Number_types/version b/Packages/Number_types/version index 201978313df..27681a62f04 100644 --- a/Packages/Number_types/version +++ b/Packages/Number_types/version @@ -1 +1 @@ -4.26 (27 Jun 2001) +4.27 (06 Jul 2001)