Qore Programming Language Reference Manual
1.9.1
|
This class defines a range-like iterator to be used to iterate numerical sequences. More...
Public Member Methods | |
constructor (int start, int stop, int step=1, auto val) | |
creates the numerical sequence iterator with the initial arguments More... | |
constructor (int stop) | |
creates the numerical sequence iterator with the initial arguments More... | |
copy () | |
Creates a copy of the RangeIterator object, iterating the same object as the original and in the same position. More... | |
auto | getValue () |
returns the current value or throws an INVALID-ITERATOR exception if the iterator is invalid More... | |
bool | next () |
This method returns True while there are more numbers to iterate and False when the range has been completely iterated. More... | |
reset () | |
Reset the iterator instance to its initial state (start, stop, and step). More... | |
bool | valid () |
returns True if the iterator is currently pointing at a valid element, False if not More... | |
This class defines a range-like iterator to be used to iterate numerical sequences.
The main purpose is to provide resource friendly iterator to generate numerical rows (sequences) with ascending and descending ordering.
The RangeIterator class provides an iterator for loop statements with functionality similar to range(). Unlike range(), RangeIterator objects do not generate real lists but calculate iteration values on demand.
This results in memory-friendly handling for large numerical sequences compared to generating a list in memory and iterating that list (as with Qore::range()).
creates the numerical sequence iterator with the initial arguments
start | an initial value |
stop | a final value |
step | is the interval. Default = 1 |
val | an optional value to be returned instead of the default integer value |
Qore::RangeIterator::constructor | ( | int | stop | ) |
creates the numerical sequence iterator with the initial arguments
stop | a final value |
Qore::RangeIterator::copy | ( | ) |
Creates a copy of the RangeIterator object, iterating the same object as the original and in the same position.
|
virtual |
returns the current value or throws an INVALID-ITERATOR
exception if the iterator is invalid
INVALID-ITERATOR
exception if the iterator is invalidINVALID-ITERATOR | the iterator is not pointing at a valid element |
ITERATOR-THREAD-ERROR | this exception is thrown if this method is called from any thread other than the thread that created the object |
Implements Qore::AbstractIterator.
|
virtual |
This method returns True while there are more numbers to iterate and False when the range has been completely iterated.
The iterator object should not be used after this method returns False.
ITERATOR-THREAD-ERROR | this exception is thrown if this method is called from any thread other than the thread that created the object |
Implements Qore::AbstractIterator.
Qore::RangeIterator::reset | ( | ) |
Reset the iterator instance to its initial state (start, stop, and step).
Reset the iterator instance to its initial state (start, stop, and step).
ITERATOR-THREAD-ERROR | this exception is thrown if this method is called from any thread other than the thread that created the object |
|
virtual |