1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
// Copyright (C) 1997 The New York Group Theory Cooperative
// See magnus/doc/COPYRIGHT for the full notice.
// Contents:
//
// Principal Author: Alexei Myasnikov
//
// Status: in progress
//
// Revision History:
//
#ifndef _SMLIST_ITERATOR_H_
#define _SMLIST_ITERATOR_H_
#include "SMList.h"
#include "Word.h"
#include "SMEnumerator.h"
//-------------------------- SMListIterator -----------------------------//
template <class T> class SMListIterator {
public:
SMListIterator(const SMList<T>& );
~SMListIterator() {
theData.closeCurrentMode();
if ( currentData )
delete currentData;
}
// Iteration procedures
bool EOL() const { return eol_reached; }
void reset();
bool nextCell();
const T& getData();
int getNumberOfElements()const { return theData.numberOfElements(); }
private:
void deleteCurrentData();
void parseData();
// Parser of an element from the list.
// Unique for each type T.
Chars currentLine;
T* currentData;
// value of the current element from the list
FPGroup theGroup;
// group
int numberOfCurrent;
// number of the last parsed element( which is the currentData)
SMListData theData;
bool eol_reached;
};
// Classes below define standards for element presentation in
// enumerators and lists.
// ---------------- WriteEnumeratorElement --------------------- //
class WriteEnumeratorElement
{
public:
WriteEnumeratorElement() {}
//@njz: moved from private
WriteEnumeratorElement(const WriteEnumeratorElement&);
//
virtual void print(ostream& ostr) const = 0;
inline friend ostream& operator << ( ostream& o,
const WriteEnumeratorElement& we ) {
// o << we.position << ":" << "$D" << " " ;
we.print( o );
return o;
}
protected:
private:
//@njz: moved to be public
// WriteEnumeratorElement(const WriteEnumeratorElement&);
//
};
// ------------------------ EnumWriteWord --------------------- //
class EnumWriteWord : public WriteEnumeratorElement
{
public:
EnumWriteWord( const Word& w, const FPGroup& g)
: theW( w ), theG( g ) { }
void print( ostream& o ) const;
private:
Word theW;
FPGroup theG;
};
// ------------------------ EnumWriteMap --------------------- //
class EnumWriteMap : public WriteEnumeratorElement
{
public:
EnumWriteMap( const Map& m )
: theM( m ) { }
void print( ostream& o ) const;
private:
Map theM;
};
// ------------------------ EnumWriteVectorOfWords --------------------- //
class EnumWriteVectorOfWords : public WriteEnumeratorElement
{
public:
EnumWriteVectorOfWords( const VectorOf<Word>& v, const FPGroup& g )
: theV( v ),
theG( g )
{ }
void print( ostream& o ) const;
private:
VectorOf<Word> theV;
FPGroup theG;
};
// ------------------------ EnumWriteSetOfWords --------------------- //
class EnumWriteSetOfWords : public WriteEnumeratorElement
{
public:
EnumWriteSetOfWords( const SetOf<Word>& s, const FPGroup& g )
: theS( s ),
theG( g )
{ }
void print( ostream& o ) const;
private:
SetOf<Word> theS;
FPGroup theG;
};
// ------------------------ EnumWriteChars --------------------- //
class EnumWriteChars : public WriteEnumeratorElement
{
public:
EnumWriteChars( const Chars& c )
: theC( c )
{ }
void print( ostream& o ) const;
private:
Chars theC;
};
#endif
|