DGtal  0.9.3beta
Public Types | Static Public Member Functions | Static Public Attributes
DGtal::NumberTraits< T > Struct Template Reference

#include <DGtal/kernel/NumberTraits.h>

Inheritance diagram for DGtal::NumberTraits< T >:
[legend]
Collaboration diagram for DGtal::NumberTraits< T >:
[legend]

Public Types

typedef TagUnknown IsBounded
 
typedef TagUnknown IsUnsigned
 
typedef TagUnknown IsSigned
 
typedef TagUnknown IsIntegral
 
typedef TagFalse IsSpecialized
 
typedef T SignedVersion
 
typedef T UnsignedVersion
 
typedef T ReturnType
 
typedef boost::call_traits< T >::param_type ParamType
 

Static Public Member Functions

static ReturnType zero ()
 
static ReturnType one ()
 
static ReturnType min ()
 
static ReturnType max ()
 
static unsigned int digits ()
 
static BoundEnum isBounded ()
 
static SignEnum isSigned ()
 
static DGtal::int64_t castToInt64_t (const T &aT)
 
static double castToDouble (const T &aT)
 
static bool even (ParamType aT)
 
static bool odd (ParamType aT)
 

Static Public Attributes

static const T ZERO = T(0)
 
static const T ONE = T(1)
 

Detailed Description

template<typename T>
struct DGtal::NumberTraits< T >

Aim: The traits class for all models of Cinteger.

Description of template class 'NumberTraits'

Since CInteger describes the concept Integer, this class is used by models of CIinteger to specialize some definitions related to Integer. For instance it defines whether a given Integer is signed or not and what is signed/unsigned version.

Examples:
arithmetic/approximation.cpp, and images/exampleConstImageAdapter.cpp.

Definition at line 69 of file NumberTraits.h.

Member Typedef Documentation

template<typename T>
typedef TagUnknown DGtal::NumberTraits< T >::IsBounded

Definition at line 72 of file NumberTraits.h.

template<typename T>
typedef TagUnknown DGtal::NumberTraits< T >::IsIntegral

Definition at line 75 of file NumberTraits.h.

template<typename T>
typedef TagUnknown DGtal::NumberTraits< T >::IsSigned

Definition at line 74 of file NumberTraits.h.

template<typename T>
typedef TagFalse DGtal::NumberTraits< T >::IsSpecialized

Definition at line 76 of file NumberTraits.h.

template<typename T>
typedef TagUnknown DGtal::NumberTraits< T >::IsUnsigned

Definition at line 73 of file NumberTraits.h.

template<typename T>
typedef boost::call_traits<T>::param_type DGtal::NumberTraits< T >::ParamType

Definition at line 83 of file NumberTraits.h.

template<typename T>
typedef T DGtal::NumberTraits< T >::ReturnType

Definition at line 79 of file NumberTraits.h.

template<typename T>
typedef T DGtal::NumberTraits< T >::SignedVersion

Definition at line 77 of file NumberTraits.h.

template<typename T>
typedef T DGtal::NumberTraits< T >::UnsignedVersion

Definition at line 78 of file NumberTraits.h.

Member Function Documentation

template<typename T>
static double DGtal::NumberTraits< T >::castToDouble ( const T &  aT)
inlinestatic

Cast method to double (for I/O or board export uses only).

Definition at line 154 of file NumberTraits.h.

Referenced by DGtal::detail::NormalizedTangentVectorFromDSS::operator()(), DGtal::detail::NormalVectorFromDCA::operator()(), and DGtal::detail::DistanceFromDCA::operator()().

155  {
156  return static_cast<double>(aT);
157  }
template<typename T>
static DGtal::int64_t DGtal::NumberTraits< T >::castToInt64_t ( const T &  aT)
inlinestatic

Cast method to DGtal::int64_t (for I/O or board export uses only).

Examples:
arithmetic/approximation.cpp.

Definition at line 146 of file NumberTraits.h.

Referenced by std::hash< DGtal::BigInteger >::operator()(), and DGtal::RayIntersectionPredicate< TPoint >::operator()().

147  {
148  return static_cast<DGtal::int64_t>(aT);
149  }
boost::int64_t int64_t
signed 94-bit integer.
Definition: BasicTypes.h:74
template<typename T>
static unsigned int DGtal::NumberTraits< T >::digits ( )
static
Returns
the number of significant digits for this integer type, or 0 if unbounded or unknown.
template<typename T>
static bool DGtal::NumberTraits< T >::even ( ParamType  aT)
inlinestatic
Parameters
aTany number.
Returns
'true' iff the number is even.

Definition at line 162 of file NumberTraits.h.

Referenced by DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::even(), and DGtal::LighterSternBrocot< TInteger, TQuotient, TMap >::Node::even().

163  {
164  return ( aT & ONE ) == ZERO;
165  }
static const T ZERO
Definition: NumberTraits.h:93
static const T ONE
Definition: NumberTraits.h:102
template<typename T>
static BoundEnum DGtal::NumberTraits< T >::isBounded ( )
static
Returns
BOUNDED, UNBOUNDED, or BOUND_UNKNOWN.
template<typename T>
static SignEnum DGtal::NumberTraits< T >::isSigned ( )
static
Returns
SIGNED, UNSIGNED or SIGN_UNKNOWN.
template<typename T>
static ReturnType DGtal::NumberTraits< T >::max ( )
static
Returns
the maximum possible value for this type of integer or ZERO if not bounded or unknown.
template<typename T>
static ReturnType DGtal::NumberTraits< T >::min ( )
static
Returns
the minimum possible value for this type of integer or ONE if not bounded or unknown.
template<typename T>
static bool DGtal::NumberTraits< T >::odd ( ParamType  aT)
inlinestatic
Parameters
aTany number.
Returns
'true' iff the number is odd.

Definition at line 170 of file NumberTraits.h.

Referenced by DGtal::LightSternBrocot< TInteger, TQuotient, TMap >::Node::odd(), and DGtal::LighterSternBrocot< TInteger, TQuotient, TMap >::Node::odd().

171  {
172  return ( aT & ONE ) != ZERO;
173  }
static const T ZERO
Definition: NumberTraits.h:93
static const T ONE
Definition: NumberTraits.h:102
template<typename T>
static ReturnType DGtal::NumberTraits< T >::one ( )
static
Returns
the one of this integer.
template<typename T>
static ReturnType DGtal::NumberTraits< T >::zero ( )
static
Returns
the zero of this integer.

Field Documentation

template<typename T>
const T DGtal::NumberTraits< T >::ONE = T(1)
static

Constant One.

Definition at line 102 of file NumberTraits.h.

template<typename T>
const T DGtal::NumberTraits< T >::ZERO = T(0)
static

Constant Zero.

Definition at line 93 of file NumberTraits.h.

Referenced by DGtal::NumberTraits< Integer >::even(), and DGtal::NumberTraits< Integer >::odd().


The documentation for this struct was generated from the following file: