AFF --- A container for numbers (array) by Friederich and Forbriger.
iterator.h
Go to the documentation of this file.
1 
51 // include guard
52 #ifndef AFF_ITERATOR_H_VERSION
53 
54 #define AFF_ITERATOR_H_VERSION \
55  "AFF_ITERATOR_H V1.4"
56 
57 #include<aff/lib/types.h>
58 
59 namespace aff {
60 
72  template<class C>
73  class Iterator {
74  public:
76  typedef C Tcontainer;
78  typedef typename C::Trepresentation Trepresentation;
80  typedef typename C::Tshape Tshape;
82  typedef typename C::Tshape::Tstepper Tstepper;
84  typedef typename C::Tvalue Tvalue;
86  typedef typename C::Treference Treference;
88  typedef typename C::Tpointer Tpointer;
90  Iterator(const C& c):
91  Mstepper(c.shape()), Mrepresentation(c.representation()) { }
92 
94 
95  bool more() const { return(Mstepper.more()); }
96  bool less() const { return(Mstepper.less()); }
97  bool valid() const { return(Mstepper.valid()); }
98  Iterator& incr() { Mstepper.incr(); return(*this); }
99  Iterator& decr() { Mstepper.decr(); return(*this); }
100  Iterator& tofirst() { Mstepper.tofirst(); return(*this); }
101  Iterator& tolast() { Mstepper.tolast(); return(*this); }
103 
106  { return(this->incr()); }
107 
110  { return(this->decr()); }
111 
113  Treference operator*()
114  { return(Mrepresentation[Mstepper.current()]); }
115 
118  { return(&(Mrepresentation[Mstepper.current()])); }
119 
120  private:
125  }; // class Iterator
126 
138  template<class C>
139  class Browser {
140  public:
142  typedef typename C::Tcontainer_of_const Tcontainer;
144  typedef typename Tcontainer::Trepresentation::Tcoc Trepresentation;
146  typedef typename Tcontainer::Tshape Tshape;
148  typedef typename Tcontainer::Tshape::Tstepper Tstepper;
150  typedef typename Tcontainer::Tconst_value Tvalue;
152  typedef typename Tcontainer::Tconst_reference Treference;
154  typedef typename Tcontainer::Tconst_pointer Tpointer;
156  Browser(const Tcontainer& c):
157  Mstepper(c.shape()), Mrepresentation(c.representation()) { }
158 
160 
161  bool more() const { return(Mstepper.more()); }
162  bool less() const { return(Mstepper.less()); }
163  bool valid() const { return(Mstepper.valid()); }
164  Browser& incr() { Mstepper.incr(); return(*this); }
165  Browser& decr() { Mstepper.decr(); return(*this); }
166  Browser& tofirst() { Mstepper.tofirst(); return(*this); }
167  Browser& tolast() { Mstepper.tolast(); return(*this); }
169 
172  { return(this->incr()); }
173 
176  { return(this->decr()); }
177 
179  Treference operator*() const
180  { return(Mrepresentation[Mstepper.current()]); }
181 
184  { return(&(Mrepresentation[Mstepper.current()])); }
185 
186  private:
191  }; // class Browser
192 
193 } // namespace aff
194 
195 #endif // AFF_ITERATOR_H_VERSION (includeguard)
196 
197 /* ----- END OF iterator.h ----- */
Tcontainer::Trepresentation::Tcoc Trepresentation
representation class
Definition: iterator.h:144
C::Tvalue Tvalue
value type
Definition: iterator.h:84
Root namespace of library.
Definition: array.h:148
C::Treference Treference
value type
Definition: iterator.h:86
Browser & decr()
delegate to stepper
Definition: iterator.h:165
C::Tshape::Tstepper Tstepper
stepper base class
Definition: iterator.h:82
some typedefs we refer to
C::Tcontainer_of_const Tcontainer
type of container
Definition: iterator.h:142
Tcontainer::Tconst_value Tvalue
value type
Definition: iterator.h:150
Iterator & tolast()
delegate to stepper
Definition: iterator.h:101
Trepresentation Mrepresentation
Representation to access.
Definition: iterator.h:124
Tstepper Mstepper
Stepper to use.
Definition: iterator.h:188
Iterator & decr()
delegate to stepper
Definition: iterator.h:99
C::Trepresentation Trepresentation
representation class
Definition: iterator.h:78
Tcontainer::Tshape Tshape
shape class
Definition: iterator.h:146
Tstepper Mstepper
Stepper to use.
Definition: iterator.h:122
Browser & operator--()
synonym for decrement
Definition: iterator.h:175
Browser.
Definition: iterator.h:139
C Tcontainer
type of container
Definition: iterator.h:76
bool more() const
delegate to stepper
Definition: iterator.h:95
Trepresentation Mrepresentation
Representation to access.
Definition: iterator.h:190
Tpointer operator->() const
member selection operator
Definition: iterator.h:183
Treference operator*()
access element
Definition: iterator.h:113
Iterator.
Definition: iterator.h:73
Tpointer operator->()
member selection operator
Definition: iterator.h:117
Iterator & operator--()
synonym for decrement
Definition: iterator.h:109
C::Tpointer Tpointer
value type
Definition: iterator.h:88
bool less() const
delegate to stepper
Definition: iterator.h:162
Browser & incr()
delegate to stepper
Definition: iterator.h:164
Browser(const Tcontainer &c)
only this constructor
Definition: iterator.h:156
Tcontainer::Tconst_pointer Tpointer
value type
Definition: iterator.h:154
bool less() const
delegate to stepper
Definition: iterator.h:96
Treference operator*() const
access element
Definition: iterator.h:179
Tcontainer::Tshape::Tstepper Tstepper
stepper base class
Definition: iterator.h:148
bool valid() const
delegate to stepper
Definition: iterator.h:163
Browser & operator++()
synonym for increment
Definition: iterator.h:171
Browser & tolast()
delegate to stepper
Definition: iterator.h:167
Iterator & incr()
delegate to stepper
Definition: iterator.h:98
Iterator & operator++()
synonym for increment
Definition: iterator.h:105
bool more() const
delegate to stepper
Definition: iterator.h:161
C::Tshape Tshape
shape class
Definition: iterator.h:80
bool valid() const
delegate to stepper
Definition: iterator.h:97
Browser & tofirst()
delegate to stepper
Definition: iterator.h:166
Iterator & tofirst()
delegate to stepper
Definition: iterator.h:100
Tcontainer::Tconst_reference Treference
value type
Definition: iterator.h:152
Iterator(const C &c)
only this constructor
Definition: iterator.h:90