DGtal  0.9.3beta
ModuloComputer.h
1 
17 #pragma once
18 
31 #if defined(ModuloComputer_RECURSES)
32 #error Recursive header files inclusion detected in ModuloComputer.h
33 #else // defined(ModuloComputer_RECURSES)
34 
35 #define ModuloComputer_RECURSES
36 
37 #if !defined ModuloComputer_h
38 
39 #define ModuloComputer_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/kernel/NumberTraits.h"
46 #include "DGtal/kernel/CInteger.h"
48 
49 namespace DGtal
50 {
51 
53  // template class ModuloComputer
78  template <typename TInteger>
80  {
81  public:
82  typedef TInteger Integer;
84 
87 
89 
94  ModuloComputer( UnsignedIntegerParamType m );
95 
100  void increment( UnsignedInteger & i ) const;
101 
106  void decrement( UnsignedInteger & i ) const;
107 
112  UnsignedInteger next( UnsignedIntegerParamType i ) const;
113 
118  UnsignedInteger previous( UnsignedIntegerParamType i ) const;
119 
125  UnsignedInteger cast( IntegerParamType i ) const;
126 
135  bool less( UnsignedIntegerParamType i, UnsignedIntegerParamType j ) const;
136 
144  UnsignedInteger posDiff( UnsignedIntegerParamType j, UnsignedIntegerParamType i ) const;
145 
146  public:
151  void selfDisplay ( std::ostream & out ) const;
152 
157  bool isValid() const;
158 
159  // ------------------------- Private Datas --------------------------------
160  private:
164  UnsignedInteger k;
165 
166  // ------------------------- Hidden services ------------------------------
167  protected:
168 
173  ModuloComputer();
174 
175  private:
176 
182  ModuloComputer ( const ModuloComputer & other );
183 
190  ModuloComputer & operator= ( const ModuloComputer & other );
191 
192  // ------------------------- Internals ------------------------------------
193  private:
194 
195  }; // end of class ModuloComputer
196 
204  template <typename T>
205  std::ostream&
206  operator<< ( std::ostream & out,
207  const ModuloComputer<T> & object )
208  {
209  object.selfDisplay( out );
210  return out;
211  }
212 
213 } // namespace DGtal
214 
215 
217 // Includes inline functions.
218 #include "DGtal/arithmetic/ModuloComputer.ih"
219 
220 // //
222 
223 #endif // !defined ModuloComputer_h
224 
225 #undef ModuloComputer_RECURSES
226 #endif // else defined(ModuloComputer_RECURSES)
bool isValid() const
UnsignedInteger next(UnsignedIntegerParamType i) const
void increment(UnsignedInteger &i) const
NumberTraits< Integer >::ParamType IntegerParamType
void selfDisplay(std::ostream &out) const
void decrement(UnsignedInteger &i) const
bool less(UnsignedIntegerParamType i, UnsignedIntegerParamType j) const
boost::call_traits< T >::param_type ParamType
Definition: NumberTraits.h:83
NumberTraits< UnsignedInteger >::ParamType UnsignedIntegerParamType
ModuloComputer & operator=(const ModuloComputer &other)
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition: CInteger.h:87
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: The traits class for all models of Cinteger.
Definition: NumberTraits.h:69
implements basic functions on modular arithmetic.
UnsignedInteger posDiff(UnsignedIntegerParamType j, UnsignedIntegerParamType i) const
UnsignedInteger previous(UnsignedIntegerParamType i) const
DGtal is the top-level namespace which contains all DGtal functions and types.
UnsignedInteger cast(IntegerParamType i) const
BOOST_CONCEPT_ASSERT((concepts::CInteger< Integer >))
NumberTraits< TInteger >::UnsignedVersion UnsignedInteger