--- parser3/src/include/pa_array.h 2003/03/08 12:22:06 1.57.2.27 +++ parser3/src/include/pa_array.h 2003/03/19 12:22:35 1.57.2.27.2.1 @@ -8,7 +8,7 @@ #ifndef PA_ARRAY_H #define PA_ARRAY_H -static const char* IDENT_ARRAY_H="$Date: 2003/03/08 12:22:06 $"; +static const char* IDENT_ARRAY_H="$Date: 2003/03/19 12:22:35 $"; // includes @@ -167,16 +167,60 @@ private: //disabled }; -/// handy array iterator +/** Array iterator, usage: + @code + // Array a; + Array_iterator i(a); + while(i.has_next()) { + T& element=i.next(); + ... + } + @endcode +*/ template class Array_iterator { + const Array& farray; + T *fcurrent; + T *flast; + +public: + + Array_iterator(const Array& aarray): farray(aarray) { + fcurrent=farray.felements; + flast=farray.felements+farray.count(); + } + + /// there are still elements + bool has_next() { + return fcurrent a; + Array_iterator i(a); + while(i.has_next()) { + T& element=i.next(); + ... + } + @endcode +*/ +template class Array_modifing_iterator { + Array& farray; T *fcurrent; T *flast; public: - Array_iterator(Array& aarray): farray(aarray) { + Array_modifing_iterator(Array& aarray): farray(aarray) { fcurrent=farray.felements; flast=farray.felements+farray.count(); }