00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OFSetIterator_h
00036 #define OFSetIterator_h
00037
00038 #include "dcmtk/config/osconfig.h"
00039 #include "dcmtk/ofstd/oftypes.h"
00040 #include "dcmtk/ofstd/ofset.h"
00041
00056 template <class T> class OFSetIterator
00057 {
00058 protected:
00059 OFSet<T> &ofset;
00060 unsigned int pos;
00061
00062 public:
00066 OFSetIterator( OFSet<T> &ofsetv )
00067 : ofset( ofsetv ), pos( 0 )
00068 {
00069 }
00070
00073 virtual ~OFSetIterator()
00074 {
00075 }
00076
00079 void ResetBeginning()
00080 {
00081 pos = 0;
00082 }
00083
00086 void ResetEnd()
00087 {
00088 unsigned int num = ofset.NumberOfElements();
00089
00090 if( num == 0 )
00091 pos = 0;
00092 else
00093 pos = num - 1;
00094 }
00095
00099 T *Object()
00100 {
00101 if( pos == ofset.NumberOfElements() )
00102 return( NULL );
00103 else
00104 return( &ofset[pos] );
00105 }
00106
00109 void Next()
00110 {
00111 if( pos < ofset.NumberOfElements() )
00112 pos++;
00113 }
00114
00117 void Prev()
00118 {
00119 unsigned int num = ofset.NumberOfElements();
00120
00121 if( pos == 0 || pos == num )
00122 pos = num;
00123 else
00124 pos--;
00125 }
00126
00131 OFBool operator==( const OFSetIterator<T> &other ) const
00132 {
00133
00134
00135 if( &ofset == &other.ofset && pos == other.pos )
00136 return( OFTrue );
00137 else
00138 return( OFFalse );
00139 }
00140
00145 OFBool operator!=( const OFSetIterator<T> &other ) const
00146 {
00147 return( !( *this == other ) );
00148 }
00149 };
00150
00151 #endif
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164