NAMD
ResizeArrayPrimIter.h
Go to the documentation of this file.
1 
7 #ifndef RAPITER_H
8 #define RAPITER_H
9 
10 #include "ResizeArray.h"
11 
12 // Don't use for speed - use iter if later we will probably want
13 // to use a better container class for better space or algorithm behavior
14 
15 template <class T> class ResizeArrayPrimIter {
16  private:
17 
18  ResizeArray<T> *array;
19  int currentIndex;
20 
21  public:
23  array = NULL;
24  currentIndex = 0;
25  }
26 
28  array = &ra;
29  currentIndex = 0;
30  }
31 
33  array = iter.array;
34  currentIndex = iter.currentIndex;
35  }
36 
38  array = iter.array;
39  currentIndex = iter.currentIndex;
40  return (*this);
41  }
42 
44 
47  iter.array = array;
48  iter.currentIndex = 0;
49  return(iter);
50  }
51 
54  iter.array = array;
55  iter.currentIndex = array->size();
56  return(iter);
57  }
58 
59  int operator!= (const ResizeArrayPrimIter<T> &iter) const {
60  return (iter.currentIndex != currentIndex || iter.array != array);
61  }
62 
63  int operator== (const ResizeArrayPrimIter<T> &iter) const {
64  return (!operator!=(iter));
65  }
66 
68  currentIndex++;
69  return (*this);
70  }
71 
73  ResizeArrayPrimIter<T> tmp(*this);
74  currentIndex++;
75  return (tmp);
76  }
77 
78  T& operator* (void) const {
79  return array->operator[](currentIndex);
80  }
81 };
82 
83 #endif
int operator!=(const ResizeArrayPrimIter< T > &iter) const
T & operator*(void) const
int operator==(const ResizeArrayPrimIter< T > &iter) const
ResizeArrayPrimIter< T > operator++(void)
ResizeArrayPrimIter< T > operator++(int)
ResizeArrayPrimIter(const ResizeArrayPrimIter< T > &iter)
ResizeArrayPrimIter< T > begin(void) const
ResizeArrayPrimIter(ResizeArray< T > &ra)
ResizeArrayPrimIter< T > & operator=(const ResizeArrayPrimIter< T > &iter)
ResizeArrayPrimIter< T > end(void) const