Java iterators for C++:
|
An iterator over a collection. More...
#include <iterJava.h>
Public Member Functions | |
iterJava () | |
Default constructor. More... | |
iterJava (Iter first, Iter end) | |
Constructor to traverse from first up to end . More... | |
iterJava (const iterJava &o) | |
Copy constructor. More... | |
~iterJava () | |
Destructor. More... | |
iterJava & | operator= (const iterJava &o) |
Copy. More... | |
bool | hasNext () const |
Returns true if the iteration has more elements. More... | |
std::iterator_traits< Iter > ::reference | next () |
Returns the next element in the iteration. More... | |
std::iterator_traits< Iter > ::reference | current () const |
Returns the value that the last invocation to next() returned. More... | |
operator Iter () const | |
Converts into an iterator over the underlying collection. More... | |
void | set (Iter first, Iter end) |
Resets the iterator to traverse from first up to end . More... | |
template<typename C > | |
void | set (C &CCC) |
Resets the iterator to traverse from C . More... | |
template<typename C > | |
void | set (const C &CCC) |
Resets the iterator to traverse from C (const version). More... | |
void | setReverse () |
Sets the iterator to go reverse (backwards). More... | |
bool | isForward () const |
Returns true if the iteration is natural, from first to last. More... | |
bool | isReverse () const |
Returns true if the iteration goes in reverse (backwards). More... | |
void | setBackward () |
Sets the iterator to go reverse (backwards). More... | |
bool | isBackward () const |
Returns true if the iteration goes in reverse (backwards). More... | |
Protected Attributes | |
Iter | itPrev |
Remember last value returned. More... | |
Iter | itNext |
Next value to return. More... | |
Iter | itEnd |
Past the last value. More... | |
bool | isFwd |
"false" if it is a reverse_iterator . More... | |
Friends | |
bool | operator== (const iterJava< Iter > &l, const iterJava< Iter > &r) |
( l == r ) ? More... | |
bool | operator!= (const iterJava< Iter > &l, const iterJava< Iter > &r) |
( l != r ) ? More... | |
An iterator over a collection.
Iterators differ from enumerations in two ways:
Iterator
takes the place of Enumeration
in the Java collections framework.const
and non-const
iterators work as expected.remove()
cannot be used.Definition at line 23 of file iterJava.h.
Default constructor.
Definition at line 30 of file iterJava.h.
Constructor to traverse from first
up to end
.
Definition at line 32 of file iterJava.h.
Copy constructor.
Definition at line 34 of file iterJava.h.
Destructor.
Definition at line 37 of file iterJava.h.
Copy.
Definition at line 38 of file iterJava.h.
|
inline |
Returns true
if the iteration has more elements.
(In other words, returns \c true if \c next() would return an element rather than breaking up.)
true
if the iterator has more elements. Definition at line 44 of file iterJava.h.
|
inline |
Returns the next element in the iteration.
Calling this method repeatedly until the \c hasNext() method returns \c false will return each element in the underlying collection exactly once.
Definition at line 48 of file iterJava.h.
|
inline |
Returns the value that the last invocation to next()
returned.
- Calling this method after the iterator was set but before the first invocation to \c next() is an error.
next()
returned. Definition at line 57 of file iterJava.h.
|
inline |
Converts into an iterator over the underlying collection.
next()
.const
and non const
iterations.next()
returned.Definition at line 58 of file iterJava.h.
|
inline |
Resets the iterator to traverse from first
up to end
.
Definition at line 60 of file iterJava.h.
Resets the iterator to traverse from C
.
Definition at line 62 of file iterJava.h.
Resets the iterator to traverse from C
(const
version).
Definition at line 64 of file iterJava.h.
|
inline |
Sets the iterator to go reverse (backwards).
next()
must not be invoked before using setReverse()
. Definition at line 66 of file iterJava.h.
|
inline |
Returns true
if the iteration is natural, from first to last.
Definition at line 75 of file iterJava.h.
|
inline |
Returns true
if the iteration goes in reverse (backwards).
- Only after \c setReverse() is invoked will \c isReverse() return \c true.
Definition at line 76 of file iterJava.h.
|
inline |
Sets the iterator to go reverse (backwards).
next()
must not be invoked before using setReverse()
.setReverse()
. Definition at line 77 of file iterJava.h.
|
inline |
Returns true
if the iteration goes in reverse (backwards).
- Only after \c setReverse() is invoked will \c isReverse() return \c true. - Handy sinomim for \c isReverse().
Definition at line 78 of file iterJava.h.
|
friend |
( l == r ) ?
Definition at line 81 of file iterJava.h.
|
friend |
( l != r ) ?
Definition at line 87 of file iterJava.h.
|
protected |
Remember last value returned.
Definition at line 25 of file iterJava.h.
|
protected |
Next value to return.
Definition at line 26 of file iterJava.h.
|
protected |
Past the last value.
Definition at line 27 of file iterJava.h.
|
protected |
"false"
if it is a reverse_iterator
.
Definition at line 28 of file iterJava.h.