File indexing completed on 2025-08-05 08:16:20
0001 #ifndef PHOOL_PHPOINTERLISTITERATOR_H
0002 #define PHOOL_PHPOINTERLISTITERATOR_H
0003
0004
0005
0006
0007
0008 #include "PHPointerList.h"
0009
0010 template <class T>
0011 class PHPointerListIterator
0012 {
0013 public:
0014 explicit PHPointerListIterator(const PHPointerList<T>&);
0015 virtual ~PHPointerListIterator() = default;
0016 T* operator()();
0017 void operator--();
0018 void reset();
0019 size_t pos() const { return m_Index; }
0020
0021 private:
0022 PHPointerListIterator() = delete;
0023 const PHPointerList<T>& m_List;
0024 size_t m_Index;
0025 };
0026
0027 template <class T>
0028 PHPointerListIterator<T>::PHPointerListIterator(const PHPointerList<T>& lis)
0029 : m_List(lis)
0030 {
0031 reset();
0032 }
0033
0034 template <class T>
0035 T* PHPointerListIterator<T>::operator()()
0036 {
0037 m_Index++;
0038 if (m_Index < m_List.length())
0039 {
0040 return m_List[m_Index];
0041 }
0042 else
0043 {
0044 return 0;
0045 }
0046 }
0047
0048 template <class T>
0049 void PHPointerListIterator<T>::operator--()
0050 {
0051 --m_Index;
0052 }
0053
0054 template <class T>
0055 void PHPointerListIterator<T>::reset()
0056 {
0057 m_Index = ~(size_t) 0;
0058 }
0059
0060 #endif