Back to index

PHPointerListIterator.h

 
//  The PHOOL's Software 
//  Copyright (C) PHENIX collaboration, 1999 
// 
//  Declaration of class PHPointerListIterator 
// 
//  Purpose: iterator for access to a PHPointerList 
// 
//  Author: Matthias Messer 
 
#ifndef PHPOINTERLISTITERATOR_H 
#define PHPOINTERLISTITERATOR_H 
 
#include "phool.h" 
#include "PHPointerList.h" 
 
template <class T>  
class PHPointerListIterator  
{  
 
public:  
  PHPointerListIterator(const PHPointerList<T> &);  
  ~PHPointerListIterator() {} 
 
public:  
   T*		operator()(); 
   void         operator--(); 
   void		reset(); 
   size_t       pos() const { return index; } 
 
protected: 
  PHPointerListIterator() : list(0) {} 
   
private:  
  const PHPointerList<T>& list; 
  size_t index;    
}; 
 
template <class T> 
PHPointerListIterator<T>::PHPointerListIterator(const PHPointerList<T>& lis)  
  : list(lis) 
{ 
  reset(); 
} 
 
template <class T> T*  
PHPointerListIterator<T>::operator()() 
{ 
   index++; 
   if (index < list.length()) 
      { 
	return list[index]; 
      } 
   else 
     { 
       return 0; 
     } 
} 
 
template <class T> void  
PHPointerListIterator<T>::operator--() 
{ 
   if (index >= 0) 
     { 
       index--; 
     } 
} 
 
template <class T> void  
PHPointerListIterator<T>::reset() 
{ 
   index =  ~(size_t) 0; 
} 
 
#endif /* PHPOINTERLISTITERATOR_H */  

Back to index