PSCF v1.1
ArrayIterator.h
1#ifndef UTIL_ARRAY_ITERATOR_H
2#define UTIL_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
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 Data* get() const
89 { return current_; }
90
92
93
99 Data& operator* () const
100 { return *current_; }
101
107 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
Forward iterator for an Array or a C array.
Definition: ArrayIterator.h:37
bool isEnd() const
Has the end of the array been reached?
Definition: ArrayIterator.h:72
Data & operator*() const
Return a reference to the current Data.
Definition: ArrayIterator.h:99
bool notEnd() const
Is the current pointer not at the end of the array?
Definition: ArrayIterator.h:80
void setEnd(Data *ptr)
Set the value of the end pointer.
Definition: ArrayIterator.h:64
Data * get() const
Return a pointer to the current data.
Definition: ArrayIterator.h:88
ArrayIterator()
Default constructor.
Definition: ArrayIterator.h:46
Data * operator->() const
Return a pointer to the current Data object.
ArrayIterator< Data > & operator++()
Increment the current pointer.
void setCurrent(Data *ptr)
Set the current pointer value.
Definition: ArrayIterator.h:56
Utility classes for scientific computation.
Definition: accumulators.mod:1