00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _VECTORENUMERATOR_H_
00011 #define _VECTORENUMERATOR_H_
00012
00013
00014 #include <vector>
00015
00016 using namespace std;
00017
00018
00019
00020
00021
00022
00023
00025
00030 class VectorEnumerator
00031 {
00032
00034
00035
00036
00038
00039 public:
00040
00042 VectorEnumerator( ) : curLength( 0 ) { }
00043
00044
00045
00046
00047
00048
00050
00051
00052
00054
00055 public:
00056
00058 VectorEnumerator& operator++( );
00059
00060
00062 vector< int > operator* ( );
00063
00064
00066 bool end( ) {
00067
00068 if( curLength==-1 )
00069 return true;
00070
00071
00072 if( !seqComplete( ) )
00073 ++(*this);
00074
00075 return (curLength==-1);
00076 }
00077
00078
00080
00081
00082
00084
00085 ostream& printSeq( ostream& os ) const;
00086
00088
00089
00090
00092
00093 protected:
00094
00096 virtual bool seqOK ( ) const = 0;
00098 virtual bool seqLimit ( ) const = 0;
00100 virtual bool seqComplete ( ) const = 0;
00101
00103 virtual int start ( ) const = 0;
00105 virtual int next ( int cur ) const = 0;
00107 virtual bool finish( int cur ) const = 0;
00108
00110 int getLength( ) const { return curLength; }
00112 const vector< int >& getSeq ( ) const { return curVector; }
00113
00115
00118 virtual void stepTo( ) { }
00120
00123 virtual void stepBack( int cur ) { }
00124
00126
00127
00128
00130
00131 private:
00132
00133 int curLength;
00134 vector< int > curVector;
00135
00136 };
00137
00138
00139
00140 #endif