lemon/tolerance.h
changeset 2159 dd3181a462d0
parent 2073 d886e4b131e6
child 2164 160ca7667159
equal deleted inserted replaced
6:029f601228d8 7:be17a1ff2d91
    47   ///\sa Tolerance<float>
    47   ///\sa Tolerance<float>
    48   ///\sa Tolerance<double>
    48   ///\sa Tolerance<double>
    49   ///\sa Tolerance<long double>
    49   ///\sa Tolerance<long double>
    50   ///\sa Tolerance<int>
    50   ///\sa Tolerance<int>
    51   ///\sa Tolerance<long long int>
    51   ///\sa Tolerance<long long int>
       
    52   ///\sa Tolerance<unsigned int>
       
    53   ///\sa Tolerance<unsigned long long int>
    52 
    54 
    53   template<class T>
    55   template<class T>
    54   class Tolerance
    56   class Tolerance
    55   {
    57   {
    56   public:
    58   public:
   269 
   271 
   270     ///Returns zero
   272     ///Returns zero
   271     static Value zero() {return 0;}
   273     static Value zero() {return 0;}
   272   };
   274   };
   273 
   275 
       
   276   ///Unsigned integer specialization of \ref Tolerance.
       
   277 
       
   278   ///Unsigned integer specialization of \ref Tolerance.
       
   279   ///\sa Tolerance
       
   280   template<>
       
   281   class Tolerance<unsigned int>
       
   282   {
       
   283   public:
       
   284     ///\e
       
   285     typedef unsigned int Value;
       
   286 
       
   287     ///\name Comparisons
       
   288     ///See \ref Tolerance for more details.
       
   289 
       
   290     ///@{
       
   291 
       
   292     ///Returns \c true if \c a is \e surely strictly less than \c b
       
   293     static bool less(Value a,Value b) { return a<b;}
       
   294     ///Returns \c true if \c a is \e surely different from \c b
       
   295     static bool different(Value a,Value b) { return a!=b; }
       
   296     ///Returns \c true if \c a is \e surely positive
       
   297     static bool positive(Value a) { return 0<a; }
       
   298     ///Returns \c true if \c a is \e surely negative
       
   299     static bool negative(Value) { return false; }
       
   300     ///Returns \c true if \c a is \e surely non-zero
       
   301     static bool nonZero(Value a) { return a!=0; };
       
   302 
       
   303     ///@}
       
   304 
       
   305     ///Returns zero
       
   306     static Value zero() {return 0;}
       
   307   };
       
   308 
   274 #ifndef __STRICT_ANSI__
   309 #ifndef __STRICT_ANSI__
   275 
   310 
   276   ///Long long integer specialization of \ref Tolerance.
   311   ///Long long integer specialization of \ref Tolerance.
   277 
   312 
   278   ///Long long integer specialization of \ref Tolerance.
   313   ///Long long integer specialization of \ref Tolerance.
   279   ///\warning This class is not ansi compatible.
   314   ///\warning This class (more exactly, type <tt>long long</tt>)
       
   315   ///is not ansi compatible.
   280   ///\sa Tolerance
   316   ///\sa Tolerance
   281   template<>
   317   template<>
   282   class Tolerance<long long int>
   318   class Tolerance<long long int>
   283   {
   319   {
   284   public:
   320   public:
   305 
   341 
   306     ///Returns zero
   342     ///Returns zero
   307     static Value zero() {return 0;}
   343     static Value zero() {return 0;}
   308   };
   344   };
   309 
   345 
       
   346   ///Unsigned long long integer specialization of \ref Tolerance.
       
   347 
       
   348   ///Unsigned long long integer specialization of \ref Tolerance.
       
   349   ///\warning This class (more exactly, type <tt>unsigned long long</tt>)
       
   350   ///is not ansi compatible.
       
   351   ///\sa Tolerance
       
   352   template<>
       
   353   class Tolerance<unsigned long long int>
       
   354   {
       
   355   public:
       
   356     ///\e
       
   357     typedef unsigned long long int Value;
       
   358 
       
   359     ///\name Comparisons
       
   360     ///See \ref Tolerance for more details.
       
   361 
       
   362     ///@{
       
   363 
       
   364     ///Returns \c true if \c a is \e surely strictly less than \c b
       
   365     static bool less(Value a,Value b) { return a<b;}
       
   366     ///Returns \c true if \c a is \e surely different from \c b
       
   367     static bool different(Value a,Value b) { return a!=b; }
       
   368     ///Returns \c true if \c a is \e surely positive
       
   369     static bool positive(Value a) { return 0<a; }
       
   370     ///Returns \c true if \c a is \e surely negative
       
   371     static bool negative(Value) { return false; }
       
   372     ///Returns \c true if \c a is \e surely non-zero
       
   373     static bool nonZero(Value a) { return a!=0;};
       
   374 
       
   375     ///@}
       
   376 
       
   377     ///Returns zero
       
   378     static Value zero() {return 0;}
       
   379   };
       
   380 
   310 #endif
   381 #endif
   311 
   382 
   312   /// @}
   383   /// @}
   313 
   384 
   314 } //namespace lemon
   385 } //namespace lemon