Jpp  18.2.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JBidirectionalIterator.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JBIDIRECTIONALITERATOR__
2 #define __JLANG__JBIDIRECTIONALITERATOR__
3 
5 
6 /**
7  * \author mdejong
8  */
9 
10 namespace JLANG {}
11 namespace JPP { using namespace JLANG; }
12 
13 namespace JLANG {
14 
15  /**
16  * Template interface for method bool decrement().
17  * This interface implements the pre-fix and post-fix operators --.
18  */
19  template<class T>
21  public JForwardIterator<T>
22  {
23  public:
24  /**
25  * Virtual destructor.
26  */
28  {}
29 
30 
31  /**
32  * Decrement iterator.
33  *
34  * \return this iterator
35  */
37  {
38  this->decrement();
39 
40  return static_cast<T&>(*this);
41  }
42 
43 
44  /**
45  * Decrement iterator.
46  *
47  * \return decrement iterator
48  */
50  {
51  const T tmp(static_cast<const T&>(*this));
52 
53  this->decrement();
54 
55  return tmp;
56  }
57 
58 
59  /**
60  * Regress iterator.
61  *
62  * \param offset offset
63  * \return iterator
64  */
65  T& operator-=(const size_t offset)
66  {
67  this->decrement(offset);
68 
69  return static_cast<T&>(*this);
70  }
71 
72 
73  /**
74  * Regress operator.
75  *
76  * \param object iterator
77  * \param offset offset
78  * \return iterator
79  */
80  friend inline T operator-(const T& object, const size_t offset)
81  {
82  T tmp(object);
83 
84  tmp.decrement(offset);
85 
86  return tmp;
87  }
88 
89 
90  /**
91  * Decrement iterator.
92  *
93  * \return true if decremented; else false
94  */
95  virtual bool decrement() = 0;
96 
97 
98  /**
99  * Decrement iterator.
100  *
101  * \param offset offset
102  * \return true if decremented; else false
103  */
104  virtual bool decrement(const size_t offset)
105  {
106  size_t i = 0;
107 
108  while (i != offset && this->decrement()) {
109  ++i;
110  }
111 
112  return i == offset;
113  }
114  };
115 }
116 
117 #endif
118 
119 
120 
Template interface for method bool increment().
T operator--(int)
Decrement iterator.
T & operator-=(const size_t offset)
Regress iterator.
virtual ~JBidirectionalIterator()
Virtual destructor.
Template interface for method bool decrement().
do set_variable OUTPUT_DIRECTORY $WORKDIR T
virtual bool decrement(const size_t offset)
Decrement iterator.
T & operator--()
Decrement iterator.
virtual bool decrement()=0
Decrement iterator.
friend T operator-(const T &object, const size_t offset)
Regress operator.