PHListIterator.h
//-----------------------------------------------------------------------------
// $Header: /afs/rhic/phenix/cvsroot/offline/framework/phool/PHListIterator.h,v 1.1 1999/08/25 18:55:05 messer Exp $
//
// The PHOOL's Software
// Copyright (C) PHENIX collaboration, 1999
//
// Declaration of class PHListIterator
//
// Purpose: iterator for access to a PHList
//
// Author: Matthias Messer
//-----------------------------------------------------------------------------
#ifndef PHLISTITERATOR_H
#define PHLISTITERATOR_H
#include "phool.h"
#include "PHList.h"
//#include "PHOperation.h"
template <class T> class PHListIterator {
public:
PHListIterator(const PHList<T> &);
~PHListIterator();
public:
T operator()();
void operator--();
void reset();
//void forEach(PHOperation<T> &);
//void for_each(PHOperation<T> &);
size_t pos() const { return index; }
private:
PHListIterator();
private:
const PHList<T>& list;
size_t index;
};
template <class T> inline PHListIterator<T>::PHListIterator()
{
}
template <class T> inline PHListIterator<T>::PHListIterator(const PHList<T>& lis) : list(lis)
{
reset();
}
template <class T> inline PHListIterator<T>::~PHListIterator()
{
}
template <class T> inline T PHListIterator<T>::operator()()
{
index++;
if (index < list.length())
return list[index];
else
return 0;
}
template <class T> inline void PHListIterator<T>::operator--()
{
if (index >= 0)
index--;
}
template <class T> inline void PHListIterator<T>::reset()
{
index = ~(size_t) 0;
}
//template <class T> inline void PHListIterator<T>::forEach(PHOperation<T>& operation)
//{
// for (int i=0; i<list.length(); i++)
// operation(list[i]);
//}
//template <class T> inline void PHListIterator<T>::for_each(PHOperation<T>& operation)
//{
// forEach(operation);
//}
#endif /* PHPOINTERLISTITERATOR_H */