SequenceGenerator< T > Class Template Reference
Inheritance diagram for SequenceGenerator< T >:

Public Member Functions

T *const & get () const override
 
bool next () override
 
 SequenceGenerator (T maxDigit_, int numDigits)
 
 ~SequenceGenerator ()
 

Private Attributes

T * digits
 
int ind
 
int len
 
maxDigit
 
int seqLen
 

Detailed Description

template<typename T>
class SequenceGenerator< T >

Definition at line 1520 of file utilities.cpp.

Constructor & Destructor Documentation

◆ SequenceGenerator()

template<typename T >
SequenceGenerator< T >::SequenceGenerator ( maxDigit_,
int  numDigits 
)
inline

Definition at line 1527 of file utilities.cpp.

1527  {
1528  ind = 0;
1529  len = numDigits;
1530  maxDigit = maxDigit_;
1531  seqLen = (int) pow(1 + (int) maxDigit, len);
1532  digits = (T*) malloc(numDigits * sizeof *digits);
1533  for (int i=0; i<numDigits; i++)
1534  digits[i] = (T) 0;
1535  ind++;
1536  }

References SequenceGenerator< T >::digits, SequenceGenerator< T >::ind, SequenceGenerator< T >::len, SequenceGenerator< T >::maxDigit, and SequenceGenerator< T >::seqLen.

◆ ~SequenceGenerator()

template<typename T >
SequenceGenerator< T >::~SequenceGenerator ( )
inline

Definition at line 1553 of file utilities.cpp.

1553  {
1554  free(digits);
1555  }

References SequenceGenerator< T >::digits.

Member Function Documentation

◆ get()

template<typename T >
T* const& SequenceGenerator< T >::get ( ) const
inlineoverride

Definition at line 1538 of file utilities.cpp.

1538  {
1539  return digits;
1540  }

References SequenceGenerator< T >::digits.

◆ next()

template<typename T >
bool SequenceGenerator< T >::next ( )
inlineoverride

Definition at line 1542 of file utilities.cpp.

1542  {
1543  bool isNext = (ind++) < seqLen;
1544  if (isNext) {
1545  int i=0;
1546  while (digits[i] == maxDigit)
1547  digits[i++] = (T) 0;
1548  digits[i] = (T) ((int) digits[i] + 1);
1549  }
1550  return isNext;
1551  }

References SequenceGenerator< T >::digits, SequenceGenerator< T >::ind, SequenceGenerator< T >::maxDigit, and SequenceGenerator< T >::seqLen.

Field Documentation

◆ digits

◆ ind

template<typename T >
int SequenceGenerator< T >::ind
private

◆ len

template<typename T >
int SequenceGenerator< T >::len
private

Definition at line 1522 of file utilities.cpp.

Referenced by SequenceGenerator< T >::SequenceGenerator().

◆ maxDigit

template<typename T >
T SequenceGenerator< T >::maxDigit
private

◆ seqLen

template<typename T >
int SequenceGenerator< T >::seqLen
private

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