PSCF v1.1
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, The Regents of the University of Minnesota
8* Distributed under the terms of the GNU General Public License.
9*/
10
11namespace Util
12{
13
36 template <typename Data>
38 {
39
40 public:
41
48 : current_(0),
49 end_(0)
50 {}
51
57 void setCurrent(Data *ptr)
58 { current_ = ptr; }
59
65 void setEnd(Data* ptr)
66 { end_ = ptr; }
67
73 bool isEnd() const
74 { return (current_ == end_); }
75
81 bool notEnd() const
82 { return (current_ != end_); }
83
89 const Data* get() const
90 { return current_; }
91
93
94
100 const Data& operator* () const
101 { return *current_; }
102
108 const Data* operator -> () const
109 { return current_; }
110
117 {
118 ++current_;
119 return *this;
120 }
121
123
124 private:
125
127 Data* current_;
128
130 Data* end_;
131
132 };
133
134}
135#endif
Forward const iterator for an Array or a C array.
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.
Definition: accumulators.mod:1