13 int IncrementIndex(std::vector<int>& i,
const std::vector<int>& imin,
const std::vector<int>& imax);
16 int IncrementIndex(std::vector<int>& i,
const std::vector<int>& imax);
20 template <
class T,
class IterT,
class MapT>
25 explicit MapIterator(MapT& _mapping):mapping(_mapping) {}
26 explicit MapIterator(IterT& _iter,MapT& _mapping):IterT(_iter),mapping(_mapping) {}
27 inline T operator*() {
return mapping(IterT::operator *()); }
28 inline bool operator == (
const MyT& rhs)
const {
return &mapping==&rhs.mapping && IterT::operator==(rhs); }
29 inline bool operator != (
const MyT& rhs)
const {
return !operator==(rhs); }
30 inline bool operator < (
const MyT& rhs)
const {
31 if(&mapping!=&rhs.mapping)
return true;
32 return IterT::operator < (rhs);
52 void enumerate(std::vector<int>& indices);
53 int operator [] (
int i)
const {
return start+stride*i; }
54 bool contains(
int index)
const;
55 int indexToElement(
int index)
const;
57 inline bool operator != (
const RangeIndices& range)
const {
return !operator==(range); }
65 inline int operator*()
const {
return index; }
66 inline int getElement()
const {
return i; }
67 void setElement(
int i);
72 bool isInvalid()
const;
73 bool operator == (
const iterator& rhs)
const;
74 inline bool operator != (
const iterator& rhs)
const {
return !operator==(rhs); }
75 bool operator < (
const iterator& rhs)
const;
86 int start,size,stride;
124 Range2Indices(
int imin,
int imax,
int istride,
int jmin,
int jmax,
int jstride);
125 void enumerate(std::vector<IntPair>& indices);
126 inline IntPair operator () (
int i,
int j)
const {
return IntPair(irange[i],jrange[j]); }
128 inline bool contains(
int iindex,
int jindex)
const {
return irange.contains(iindex) && jrange.contains(jindex); }
129 inline bool contains(
const IntPair& t)
const {
return contains(t.a,t.b); }
130 inline IntPair indexToElement(
int iindex,
int jindex)
const {
return IntPair(irange.indexToElement(iindex),jrange.indexToElement(jindex)); }
139 inline int getElement()
const {
return element; }
140 void setElement(
int k);
141 void setElement(
int i,
int j);
142 void setElement(
const IntPair& t) { setElement(t.a,t.b); }
147 inline int getFirst()
const {
return *i; }
148 inline int getSecond()
const {
return *j; }
149 inline int getFirstElement()
const {
return i.getElement(); }
150 inline int getSecondElement()
const {
return j.getElement(); }
151 inline void incFirst(
int skip=1) { i+=skip; }
152 inline void incSecond(
int skip=1) { j+=skip; }
153 inline bool isInvalid()
const {
return i.isInvalid() || j.isInvalid(); }
154 inline bool operator == (
const iterator& rhs)
const {
return i==rhs.i && j==rhs.j; }
155 inline bool operator != (
const iterator& rhs)
const {
return !operator==(rhs); }
156 bool operator < (
const iterator& rhs)
const;
181 Range3Indices(
int imin,
int imax,
int jmin,
int jmax,
int kmin,
int kmax);
182 void enumerate(std::vector<IntTriple>& indices);
183 inline IntTriple operator () (
int i,
int j,
int k)
const 184 {
return IntTriple(irange[i],jrange[j],krange[k]); }
186 {
return IntTriple(irange[t.a],jrange[t.b],krange[t.c]); }
187 inline bool contains(
int iindex,
int jindex,
int kindex)
const {
return irange.contains(iindex) && jrange.contains(jindex) && krange.contains(kindex); }
188 inline bool contains(
const IntTriple& t)
const 189 {
return contains(t.a,t.b,t.c); }
190 inline IntTriple indexToElement(
int iindex,
int jindex,
int kindex)
const {
191 return IntTriple(irange.indexToElement(iindex),
192 jrange.indexToElement(jindex),
193 krange.indexToElement(kindex)); }
202 inline int getElement()
const {
return element; }
203 void setElement(
int m);
204 void setElement(
int i,
int j,
int k);
205 void setElement(
const IntTriple& t) { setElement(t.a,t.b,t.c); }
210 inline int getFirst()
const {
return *i; }
211 inline int getSecond()
const {
return *j; }
212 inline int getThird()
const {
return *k; }
213 inline int getFirstElement()
const {
return i.getElement(); }
214 inline int getSecondElement()
const {
return j.getElement(); }
215 inline int getThirdElement()
const {
return k.getElement(); }
216 inline void incFirst(
int skip=1) { i+=skip; }
217 inline void incSecond(
int skip=1) { j+=skip; }
218 inline void incThird(
int skip=1) { k+=skip; }
219 inline bool isInvalid()
const {
return i.isInvalid() || j.isInvalid() || k.isInvalid(); }
220 inline bool operator == (
const iterator& rhs)
const {
return i==rhs.i && j==rhs.j && k==rhs.k; }
221 inline bool operator != (
const iterator& rhs)
const {
return !operator==(rhs); }
222 bool operator < (
const iterator& rhs)
const;
245 Stripe2Indices(
int isize,
int jsize,
int base=0,
int istride=1,
int jstride=1);
249 void enumerate(std::vector<int>& indices);
250 inline int operator () (
int i,
int j)
const {
return base+i*istride+j*jstride; }
251 inline int operator () (
const IntPair& t)
const {
return operator()(t.a,t.b); }
252 bool contains(
int index)
const;
253 IntPair indexToElement(
int index)
const;
256 inline bool operator != (
const Stripe2Indices& stripe)
const {
return !operator==(stripe); }
263 inline int operator*()
const {
return index; }
269 void incFirst(
int skip=1);
270 void incSecond(
int skip=1);
271 bool isInvalid()
const;
272 bool operator == (
const iterator& rhs)
const;
273 inline bool operator != (
const iterator& rhs)
const {
return !operator==(rhs); }
274 bool operator < (
const iterator& rhs)
const;
278 int index,stripeIndex;
299 Stripe3Indices(
int isize,
int jsize,
int ksize,
int base=0,
int istride=1,
int jstride=1,
int kstride=1);
303 void enumerate(std::vector<int>& indices);
304 inline int operator () (
int i,
int j,
int k)
const {
return base+i*istride+j*jstride+k*kstride; }
305 inline int operator () (
const IntTriple& t)
const {
return operator()(t.a,t.b,t.c); }
306 bool contains(
int index)
const;
307 IntTriple indexToElement(
int index)
const;
310 inline bool operator != (
const Stripe3Indices& stripe)
const {
return !operator==(stripe); }
317 inline int operator*()
const {
return index; }
323 void incFirst(
int skip=1);
324 void incSecond(
int skip=1);
325 void incThird(
int skip=1);
326 bool isInvalid()
const;
327 bool operator == (
const iterator& rhs)
const;
328 inline bool operator != (
const iterator& rhs)
const {
return !operator==(rhs); }
329 bool operator < (
const iterator& rhs)
const;
333 int index,firstIndex,secondIndex;
340 int isize,jsize,ksize;
341 int istride,jstride,kstride;
352 void enumerate(std::vector<IntPair>& indices);
353 inline IntPair operator () (
int i,
int j)
const {
return IntPair(iindices[i],jindices[j]); }
354 inline IntPair operator () (
const IntPair& t)
const {
return operator() (t.a,t.b); }
355 inline bool contains(
int iindex,
int jindex)
const {
return iindices.contains(iindex) && jindices.contains(jindex); }
365 IntPair i=ParentT::operator *();
368 inline int getFirst()
const {
return grid->iindices[ParentT::getFirst()]; }
369 inline int getSecond()
const {
return grid->jindices[ParentT::getSecond()]; }
370 inline bool operator == (
const iterator& rhs)
const {
return grid==rhs.grid && ParentT::operator==(rhs); }
371 inline bool operator != (
const iterator& rhs)
const {
return !operator==(rhs); }
372 inline bool operator < (
const iterator& rhs)
const {
return ParentT::operator < (rhs); }
A lightweight integer 3-tuple class.
Definition: IntTriple.h:9
A regular range of indices ik = start+k*stride, for k=0 to size-1.
Definition: utils/indexing.h:45
Definition: utils/indexing.h:132
A 2D lattice of irregular ranges.
Definition: utils/indexing.h:350
Definition: utils/indexing.h:357
A lightweight integer 2-tuple class.
Definition: IntPair.h:9
A 3D lattice of regular ranges.
Definition: utils/indexing.h:175
An integer tuple class.
Definition: IntTuple.h:14
Definition: utils/indexing.h:21
Definition: utils/indexing.h:312
Definition: utils/indexing.h:258
A 2D lattice of regular ranges.
Definition: utils/indexing.h:116
Definition: utils/indexing.h:195
Definition: utils/indexing.h:59
A 2D lattice indexing into a linear sequence, in a striping pattern.
Definition: utils/indexing.h:241
A 3D lattice indexing into a linear sequence, in a striping pattern.
Definition: utils/indexing.h:295