May be it will be good to copy some features from STL? (I mean return values for operators) It will be much more convenient to use the iterator then.
Requirements for Bidirectional Iterators
A bidirectional iterator must meet all the requirements for forward iterators. In addition, the following expressions must be valid:
--r returns X&
r-- return value convertible to const X&
*r-- returns T
Requirements for Random Access Iterators
A random access iterator must meet all the requirements for bidirectional iterators. In addition, the following expressions must be valid:
r += n Semantics of --r or ++r n times depending on the sign of n
a + n, n + a returns type X
r -= n returns X&, behaves as r += -n
a - n returns type X
b - a returns distance
a[n] *(a+n), return value convertible to T
a < b total ordering relation
a > b total ordering relation opposite to <
a <= b !(a > b)
a >= b !(a < b)
All relational operators return a value convertible to bool.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I agree it would be usefull to have these. I've changed the
++x and --x to return refrences to the class so you can use
things like if(--x) {} or *(++x) as the symantics are consistant with C/C++ pointers. Not so keen on *x++ because in C++ pointers it would access the element before the increment, but it RAVL iterators it would have to access the value after.
I've added to the 1d array iterators the following.
a < b total ordering relation
a > b total ordering relation opposite to <
a <= b !(a > b)
a >= b !(a < b)
r += n Semantics of --r or ++r n times depending on the sign of n
r -= n returns X&, behaves as r += -n
and will look at adding the rest of the operators.
I'm not so keen on adding ordering operators to DLIterC, as they would be expensive operations, and it would be better for the user to keep track of the info in their own code.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
May be it will be good to copy some features from STL? (I mean return values for operators) It will be much more convenient to use the iterator then.
Requirements for Bidirectional Iterators
A bidirectional iterator must meet all the requirements for forward iterators. In addition, the following expressions must be valid:
--r returns X&
r-- return value convertible to const X&
*r-- returns T
Requirements for Random Access Iterators
A random access iterator must meet all the requirements for bidirectional iterators. In addition, the following expressions must be valid:
r += n Semantics of --r or ++r n times depending on the sign of n
a + n, n + a returns type X
r -= n returns X&, behaves as r += -n
a - n returns type X
b - a returns distance
a[n] *(a+n), return value convertible to T
a < b total ordering relation
a > b total ordering relation opposite to <
a <= b !(a > b)
a >= b !(a < b)
All relational operators return a value convertible to bool.
I agree it would be usefull to have these. I've changed the
++x and --x to return refrences to the class so you can use
things like if(--x) {} or *(++x) as the symantics are consistant with C/C++ pointers. Not so keen on *x++ because in C++ pointers it would access the element before the increment, but it RAVL iterators it would have to access the value after.
I've added to the 1d array iterators the following.
a < b total ordering relation
a > b total ordering relation opposite to <
a <= b !(a > b)
a >= b !(a < b)
r += n Semantics of --r or ++r n times depending on the sign of n
r -= n returns X&, behaves as r += -n
and will look at adding the rest of the operators.
I'm not so keen on adding ordering operators to DLIterC, as they would be expensive operations, and it would be better for the user to keep track of the info in their own code.