PSCF v1.5.0
ConstArrayIterator.h
1#ifndef UTIL_CONST_ARRAY_ITERATOR_H
2#define UTIL_CONST_ARRAY_ITERATOR_H
3
4/*
5* Util Package - C++ Utilities for Scientific Computation
6*
7* Copyright 2010 - 2017, David Morse (morse012@um.edu)
8* Distributed under the terms of the GNU General Public License.
9*/
10
11namespace Util
12{
13
35 template <typename Data>
37 {
38
39 public:
40
47 : current_(0),
48 end_(0)
49 {}
50
56 void setCurrent(Data *ptr)
57 { current_ = ptr; }
58
64 void setEnd(Data* ptr)
65 { end_ = ptr; }
66
72 bool isEnd() const
73 { return (current_ == end_); }
74
80 bool notEnd() const
81 { return (current_ != end_); }
82
88 const Data* get() const
89 { return current_; }
90
92
93
99 const Data& operator* () const
100 { return *current_; }
101
107 const Data* operator -> () const
108 { return current_; }
109
116 {
117 ++current_;
118 return *this;
119 }
120
122
123 private:
124
126 Data* current_;
127
129 Data* end_;
130
131 };
132
133}
134#endif
void setEnd(Data *ptr)
Set the value of the end pointer.
void setCurrent(Data *ptr)
Set the current pointer value.
bool notEnd() const
Is this not the end of the array?
const Data * get() const
Return a pointer to the current data.
const Data * operator->() const
Provide a pointer to the current Data object.
ConstArrayIterator< Data > & operator++()
Increment the current pointer.
bool isEnd() const
Has the end of the array been reached?
ConstArrayIterator()
Default constructor.
const Data & operator*() const
Get a reference to the current Data.
Utility classes for scientific computation.