TabulatedFunctionIterators.h
Go to the documentation of this file.
1 
9 #ifndef _utl_TabulatedFunctionIterators_h_
10 #define _utl_TabulatedFunctionIterators_h_
11 
12 #include <utl/Pair.h>
13 #include <utl/PairErr.h>
14 
15 #include <vector>
16 #include <cstddef>
17 
18 
19 namespace utl {
20 
21  // Custom Iterators
22 
24  public std::iterator<std::input_iterator_tag, Pair, ptrdiff_t> {
25 
26  private:
27  typedef std::vector<double>::iterator InternalIterator;
28 
29  public:
31 
33  fXIterator(xIt), fYIterator(yIt) { }
34 
35  Pair operator*() const
36  { return Pair(*fXIterator, *fYIterator); }
37 
38  Pair* operator->() const
39  { fPair = Pair(*fXIterator, *fYIterator); return &fPair; }
40 
42  { ++fXIterator; ++fYIterator; return *this; }
43 
45  { const TabulatedFunctionIterator tmp = *this; ++fXIterator; ++fYIterator; return tmp; }
46 
47  bool operator==(const TabulatedFunctionIterator& it) const
48  { return fXIterator == it.fXIterator && fYIterator == it.fYIterator; }
49 
50  bool operator!=(const TabulatedFunctionIterator& it) const
51  { return fXIterator != it.fXIterator || fYIterator != it.fYIterator; }
52 
53  private:
54  mutable Pair fPair;
55 
58 
60 
61  };
62 
63 
65  public std::iterator<std::input_iterator_tag, Pair, ptrdiff_t> {
66 
67  private:
68  typedef std::vector<double>::const_iterator InternalIterator;
69 
70  public:
72 
75 
77  fXIterator(xIt), fYIterator(yIt) { }
78 
79  Pair operator*() const
80  { return Pair(*fXIterator, *fYIterator); }
81 
82  const Pair* operator->() const
83  { fPair = Pair(*fXIterator, *fYIterator); return &fPair; }
84 
86  { ++fXIterator; ++fYIterator; return *this; }
87 
89  { const ConstTabulatedFunctionIterator tmp = *this;
90  ++fXIterator; ++fYIterator; return tmp; }
91 
93  { return fXIterator == it.fXIterator && fYIterator == it.fYIterator; }
94 
96  { return fXIterator != it.fXIterator || fYIterator != it.fYIterator; }
97 
98  private:
99  mutable Pair fPair;
100 
103 
104  };
105 
106  // Forward declaration to allow TabulatedFunctionErrors friend access to
107  // the InternalIterators of the TabulatedFunctionErrIterator
109 
111  public std::iterator<std::input_iterator_tag, PairErr, ptrdiff_t> {
112 
113  private:
114  typedef std::vector<double>::iterator InternalIterator;
115 
116  public:
118 
120  const InternalIterator yIt, const InternalIterator yErrIt) :
121  fXIterator(xIt), fXErrIterator(xErrIt), fYIterator(yIt), fYErrIterator(yErrIt) { }
122 
125 
128 
130  { ++fXIterator; ++fXErrIterator; ++fYIterator; ++fYErrIterator; return *this; }
131 
133  { const TabulatedFunctionErrIterator tmp = *this;
134  ++fXIterator; ++fXErrIterator; ++fYIterator; ++fYErrIterator; return tmp; }
135 
137  { return fXIterator == it.fXIterator && fXErrIterator == it.fXErrIterator &&
139 
141  { return fXIterator != it.fXIterator || fXErrIterator != it.fXErrIterator ||
143 
144  private:
145  mutable PairErr fPair;
146 
151 
153 
154  };
155 
156 
158  public std::iterator<std::input_iterator_tag, PairErr, ptrdiff_t> {
159 
160  private:
161  typedef std::vector<double>::const_iterator InternalIterator;
162 
163  public:
165 
167  const InternalIterator yIt, const InternalIterator yErrIt) :
168  fXIterator(xIt), fXErrIterator(xErrIt), fYIterator(yIt), fYErrIterator(yErrIt) { }
169 
172 
173  const PairErr* operator->() const
175 
177  { ++fXIterator; ++fXErrIterator; ++fYIterator; ++fYErrIterator; return *this; }
178 
180  { const ConstTabulatedFunctionErrIterator tmp = *this;
181  ++fXIterator; ++fXErrIterator; ++fYIterator; ++fYErrIterator; return tmp; }
182 
184  { return fXIterator == it.fXIterator && fXErrIterator == it.fXErrIterator &&
186 
188  { return fXIterator != it.fXIterator || fXErrIterator != it.fXErrIterator ||
190 
191  private:
192  mutable PairErr fPair;
193 
198 
200 
201  };
202 
203 }
204 
205 
206 #endif
bool operator==(const TabulatedFunctionIterator &it) const
std::vector< double >::const_iterator InternalIterator
bool operator==(const ConstTabulatedFunctionIterator &it) const
ConstTabulatedFunctionErrIterator & operator++()
A pair of graph points (x,y) with errors.
Definition: PairErr.h:17
TabulatedFunctionIterator(const InternalIterator xIt, const InternalIterator yIt)
bool operator==(const ConstTabulatedFunctionErrIterator &it) const
bool operator!=(const ConstTabulatedFunctionErrIterator &it) const
TabulatedFunctionErrIterator operator++(int)
ConstTabulatedFunctionIterator operator++(int)
ConstTabulatedFunctionIterator(const TabulatedFunctionIterator it)
bool operator==(const TabulatedFunctionErrIterator &it) const
TabulatedFunctionIterator operator++(int)
ConstTabulatedFunctionErrIterator(const InternalIterator xIt, const InternalIterator xErrIt, const InternalIterator yIt, const InternalIterator yErrIt)
std::vector< double >::const_iterator InternalIterator
std::vector< double >::iterator InternalIterator
bool operator!=(const TabulatedFunctionErrIterator &it) const
TabulatedFunctionErrIterator(const InternalIterator xIt, const InternalIterator xErrIt, const InternalIterator yIt, const InternalIterator yErrIt)
std::vector< double >::iterator InternalIterator
ConstTabulatedFunctionIterator & operator++()
bool operator!=(const ConstTabulatedFunctionIterator &it) const
TabulatedFunctionIterator & operator++()
ConstTabulatedFunctionErrIterator operator++(int)
bool operator!=(const TabulatedFunctionIterator &it) const
a pair of graph points (x,y)
Definition: Pair.h:25
TabulatedFunctionErrIterator & operator++()
ConstTabulatedFunctionIterator(const InternalIterator xIt, const InternalIterator yIt)

, generated on Tue Sep 26 2023.