/*
** ODOMETER(): Generalized odometer object.  Each `digit' can have its
**   own min and max values (and actually each position can be filled by an
**   integer, not just a single digit).  The low-index digits are the 
**   faster moving ones.  There is also a special lexical increment which
**   ensures that digit i is greater than digit i+1.
**
**   Methods:
**      Odometer(): Default constructor gives 0 digits and all NULL arrays.
**      Odometer(int n): Construct an odometer with n digits
**      ~Odometer(): Free's the dynamically allocated memory
**      size(int m): Set the length of a default-constructed odometer to m
**      resize(int m): Change the length of an odometer to m
**      set_max(int m): set the maximum for every digit to m
**      set_max(int *m): set the max for each digit according to array m
**      set_min(int m), set_min(int *m): similar to set_max()
**      set_value(int m), set_value(int *m): similar to set_max()
**      set_max_lex(int m): set max values for each digit such that the
**         lowest index digit has max m, the next has max m-1, etc.
**      set_min_lex(int m): set min values for each digit such that the
**         highest index digit has min m, the next has min m-1, etc.
**      get_value(int *m): copy the values array into array m
**      increment(): increment the odometer (at position 0)
**      increment_lex(): lexical index...increment but make sure that
**         value[i] > value[i+1]
**      reset(): return all digits to their min values
**      print(): print out odometer reading (high index digits first)
**      at_max(): has the odometer reached its maximum reading? (1 or 0)
**      at_min(): has the odometer reached its minimum reading? (1 or 0)
**      get_length(): returns the length (number of digits) of the odometer
**      boundscheck(): make sure max's are > min's, and vice versa
**
*/

class Odometer {

   protected:
      unsigned length ;
      int* max ;
      int* min ;
      int* value ;
       
   public:
      Odometer() ;
      Odometer(unsigned len) { size(len); }
      ~Odometer() ; 
      
      void size(unsigned s) ;
      void resize(unsigned s) ;
      void set_max(int m) ;
      void set_max_lex(int m) ;
      void set_max(int* m) ;
      void set_min(int m) ;
      void set_min_lex(int m) ;
      void set_min(int* m) ;
      void set_value(int m) ;
      void set_value(int* m) ;
      void get_value(int* m) ;
      void increment() ;
      void increment_lex() ;
      void reset() ;
      void print() ;
      unsigned at_max() ;
      unsigned at_min() ;
      unsigned get_length() 
         {return length; }
      unsigned boundscheck() ;
} ;

