1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
// Copyright (c) 1997 Utrecht University (The Netherlands),
// ETH Zurich (Switzerland), Freie Universitaet Berlin (Germany),
// INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg
// (Germany), Max-Planck-Institute Saarbruecken (Germany), RISC Linz (Austria),
// and Tel-Aviv University (Israel). All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; version 2.1 of the License.
// See the file LICENSE.LGPL distributed with CGAL.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.2-branch/Number_types/include/CGAL/number_utils_classes.h $
// $Id: number_utils_classes.h 28567 2006-02-16 14:30:13Z lsaboret $
//
//
// Author(s) : Michael Hoffmann <hoffmann@inf.ethz.ch>
// to be included by number_utils.h
#ifndef CGAL_NUMBER_UTILS_CLASSES_H
#define CGAL_NUMBER_UTILS_CLASSES_H 1
#include <CGAL/config.h>
#include <algorithm>
#include <utility>
#include <CGAL/functional_base.h>
#include <CGAL/number_utils_fwd.h>
CGAL_BEGIN_NAMESPACE
template < class NT1, class NT2 = NT1 >
struct Equal_to : public Binary_function< NT1, NT2, bool > {
bool operator()( const NT1& x, const NT2& y) const
{ return x == y; }
};
template < class NT1, class NT2 = NT1 >
struct Not_equal_to : public Binary_function< NT1, NT2, bool > {
bool operator()( const NT1& x, const NT2& y) const
{ return x != y; }
};
template < class NT1, class NT2 = NT1 >
struct Greater : public Binary_function< NT1, NT2, bool > {
bool operator()( const NT1& x, const NT2& y) const
{ return x > y; }
};
template < class NT1, class NT2 = NT1 >
struct Less : public Binary_function< NT1, NT2, bool > {
bool operator()( const NT1& x, const NT2& y) const
{ return x < y; }
};
template < class NT1, class NT2 = NT1 >
struct Greater_equal : public Binary_function< NT1, NT2, bool > {
bool operator()( const NT1& x, const NT2& y) const
{ return x >= y; }
};
template < class NT1, class NT2 = NT1 >
struct Less_equal : public Binary_function< NT1, NT2, bool > {
bool operator()( const NT1& x, const NT2& y) const
{ return x <= y; }
};
template < class NT >
struct Is_zero :public Unary_function< NT, bool > {
bool operator()( const NT& x) const
{ return CGAL_NTS is_zero( x); }
};
template < class NT >
struct Is_one :public Unary_function< NT, bool > {
bool operator()( const NT& x) const
{ return CGAL_NTS is_one( x); }
};
template < class NT >
struct Is_negative :public Unary_function< NT, bool > {
bool operator()( const NT& x) const
{ return CGAL_NTS is_negative( x); }
};
template < class NT >
struct Is_positive :public Unary_function< NT, bool > {
bool operator()( const NT& x) const
{ return CGAL_NTS is_positive( x); }
};
// Sign would result in a name clash with enum.h
template < class NT >
struct Sgn :public Unary_function< NT, Sign > {
Sign operator()( const NT& x) const
{ return CGAL_NTS sign( x); }
};
template < class NT >
struct Abs :public Unary_function< NT, NT > {
NT operator()( const NT& x) const
{ return CGAL_NTS abs( x); }
};
template < class NT, class Compare = std::less< NT > >
struct Min :public Binary_function< NT, NT, NT > {
Min() {}
Min(const Compare& c_) : c(c_) {}
NT operator()( const NT& x, const NT& y) const
{ return min( x, y, c); }
protected:
Compare c;
};
template < class NT, class Compare = std::less< NT > >
struct Max :public Binary_function< NT, NT, NT > {
Max() {}
Max(const Compare& c_) : c(c_) {}
NT operator()( const NT& x, const NT& y) const
{ return max( x, y, c); }
protected:
Compare c;
};
template < class NT >
struct Compare
:public Binary_function< NT, NT, Comparison_result > {
Comparison_result operator()( const NT& x, const NT& y) const
{ return CGAL_NTS compare( x, y); }
};
template < class NT >
struct Square : public Unary_function< NT, NT > {
NT operator()( const NT& x) const
{ return CGAL_NTS square( x ); }
};
template < class NT >
struct Sqrt : public Unary_function< NT, NT > {
NT operator()( const NT& x) const
{ return CGAL_NTS sqrt( x ); }
};
template < class NT >
struct Div : public Binary_function< NT, NT, NT > {
NT operator()( const NT& x, const NT& y) const
{ return CGAL_NTS div( x, y ); }
};
template < class NT >
struct Gcd : public Binary_function< NT, NT, NT > {
NT operator()( const NT& x, const NT& y) const
{ return CGAL_NTS gcd( x, y ); }
};
template < class NT >
struct To_double : public Unary_function< NT, double > {
double operator()( const NT& x) const
{ return CGAL_NTS to_double( x ); }
};
template < class NT >
struct To_interval
: public Unary_function< NT, std::pair<double, double> >
{
std::pair<double, double> operator()( const NT& x) const
{ return CGAL_NTS to_interval( x ); }
};
CGAL_END_NAMESPACE
#endif // CGAL_NUMBER_UTILS_CLASSES_H
|