Class VectorEnumerator. More...
#include <VectorEnumerator.h>
Public Member Functions | |
VectorEnumerator () | |
Default constructor. | |
VectorEnumerator & | operator++ () |
Compute the next element. | |
vector< int > | operator* () |
Get the current element. | |
bool | end () |
Returns true if there are no more elements to enumerate. | |
ostream & | printSeq (ostream &os) const |
Protected Member Functions | |
virtual bool | seqOK () const =0 |
Check if the currently constructed sequence is legitimate. | |
virtual bool | seqLimit () const =0 |
Returns true if the length-limit on the sequence is passed. | |
virtual bool | seqComplete () const =0 |
Returns true if the current sequence is complete. | |
virtual int | start () const =0 |
Returns the initial value for the current element of the sequence (usually 0). | |
virtual int | next (int cur) const =0 |
Returns the next value for the current element of the sequence (usually cur+1). | |
virtual bool | finish (int cur) const =0 |
int | getLength () const |
Get the length of the current sequence. | |
const vector< int > & | getSeq () const |
Get the current sequence. | |
virtual void | stepTo () |
Function is invoked when the current value of the current element of the sequence is accepted and we go for the next element. | |
virtual void | stepBack (int cur) |
Function is invoked when we go backward from the current element to the previous element. | |
Private Attributes | |
int | curLength |
vector< int > | curVector |
Class VectorEnumerator.
VectorEnumerator provides the ground-level interface for vector-enumerators (for instance it can be used for enumeration of permutations, finite sequences over finite alphabet, etc.).
Definition at line 31 of file VectorEnumerator.h.
VectorEnumerator::VectorEnumerator | ( | ) | [inline] |
Default constructor.
Definition at line 43 of file VectorEnumerator.h.
bool VectorEnumerator::end | ( | ) | [inline] |
Returns true if there are no more elements to enumerate.
Definition at line 67 of file VectorEnumerator.h.
References curLength, and seqComplete().
virtual bool VectorEnumerator::finish | ( | int | cur | ) | const [protected, pure virtual] |
Implemented in PermutationEnumerator.
int VectorEnumerator::getLength | ( | ) | const [inline, protected] |
Get the length of the current sequence.
Definition at line 111 of file VectorEnumerator.h.
References curLength.
Referenced by PermutationEnumerator::seqComplete(), PermutationEnumerator::seqLimit(), PermutationEnumerator::seqOK(), PermutationEnumerator::stepBack(), and PermutationEnumerator::stepTo().
const vector< int >& VectorEnumerator::getSeq | ( | ) | const [inline, protected] |
Get the current sequence.
Definition at line 113 of file VectorEnumerator.h.
References curVector.
Referenced by PermutationEnumerator::getPermutation(), PermutationEnumerator::seqOK(), PermutationEnumerator::stepBack(), and PermutationEnumerator::stepTo().
virtual int VectorEnumerator::next | ( | int | cur | ) | const [protected, pure virtual] |
Returns the next value for the current element of the sequence (usually cur+1).
Implemented in PermutationEnumerator.
vector< int > VectorEnumerator::operator* | ( | ) |
Get the current element.
VectorEnumerator& VectorEnumerator::operator++ | ( | ) |
Compute the next element.
ostream& VectorEnumerator::printSeq | ( | ostream & | os | ) | const |
virtual bool VectorEnumerator::seqComplete | ( | ) | const [protected, pure virtual] |
Returns true if the current sequence is complete.
Implemented in PermutationEnumerator.
Referenced by end().
virtual bool VectorEnumerator::seqLimit | ( | ) | const [protected, pure virtual] |
Returns true if the length-limit on the sequence is passed.
Implemented in PermutationEnumerator.
virtual bool VectorEnumerator::seqOK | ( | ) | const [protected, pure virtual] |
Check if the currently constructed sequence is legitimate.
Implemented in PermutationEnumerator.
virtual int VectorEnumerator::start | ( | ) | const [protected, pure virtual] |
Returns the initial value for the current element of the sequence (usually 0).
Implemented in PermutationEnumerator.
virtual void VectorEnumerator::stepBack | ( | int | cur | ) | [inline, protected, virtual] |
Function is invoked when we go backward from the current element to the previous element.
The value of curElement is already decreased, so you are at the previous element
Reimplemented in PermutationEnumerator.
Definition at line 124 of file VectorEnumerator.h.
virtual void VectorEnumerator::stepTo | ( | ) | [inline, protected, virtual] |
Function is invoked when the current value of the current element of the sequence is accepted and we go for the next element.
The value of curElement is already increased, so you are at the next element.
Reimplemented in PermutationEnumerator.
Definition at line 119 of file VectorEnumerator.h.
int VectorEnumerator::curLength [private] |
Definition at line 134 of file VectorEnumerator.h.
Referenced by end(), and getLength().
vector< int > VectorEnumerator::curVector [private] |
Definition at line 135 of file VectorEnumerator.h.
Referenced by getSeq().