#include <OTC/collctn/iterator.hh> template<class T> class OTC_Iterator {
public:
static os_typespec* get_os_typespec();
inline ~OTC_Iterator();
inline OTC_Iterator();
inline OTC_Iterator(OTC_Cursor<T>* anIter);
inline OTC_Iterator(OTC_Iterator<T> const& anIter);
inline OTC_Iterator<T>& operator=(OTC_Cursor<T>* anIter);
inline OTC_Iterator<T>& operator=(OTC_Iterator<T> const& anIter);
inline void next();
inline void reset();
inline T const& item() const;
inline OTC_Boolean isValid() const;
inline OTC_Iterator<T> clone() const;
inline void apply(OTC_Visitor<T>& theApplicator);
protected:
inline T& _item() const;
inline OTC_Cursor<T>* _clone() const;
inline void _apply(OTC_Visitor<T>& theApplicator);
inline void _apply(OTC_Worker<T>& theApplicator);
};
new
.
void sum(OTC_Collection<int> const& aCollection)
{
OTC_Iterator<int> anIter = 0;
anIter = aCollection.items();
int i=0;
for (anIter.reset(); anIter.isValid(); anIter.next())
i += anIter.item();
cout << i << endl;
}
inline OTC_Iterator();
inline OTC_Iterator(OTC_Cursor<T>* anIter);
0
will
result in a null iterator being
constructed.
inline OTC_Iterator(OTC_Iterator<T> const& anIter);
inline OTC_Iterator<T>& operator=(OTC_Cursor<T>* anIter);
anIter
.
If anIter
is 0
, the iterator
is turned into a null iterator and
all associations with the previous
collection are lost.
inline OTC_Iterator<T>& operator=(OTC_Iterator<T> const& anIter);
anIter
.
inline void next();
inline void reset();
inline T const& item() const;
inline OTC_Boolean isValid() const;
OTCLIB_TRUE
while there is a
valid data item under the current location
of the iterator.
inline OTC_Iterator<T> clone() const;
inline void apply(OTC_Visitor<T>& theApplicator);
theApplicator
to each item
accessible by this iterator.