Qore Programming Language Reference Manual 1.14.2
Loading...
Searching...
No Matches
Qore::AbstractBidirectionalIterator Class Referenceabstract

This class defines an abstract interface for bidirectional iterators. More...

#include <QC_AbstractBidirectionalIterator.dox.h>

Inheritance diagram for Qore::AbstractBidirectionalIterator:
[legend]

Public Member Methods

abstract bool prev ()
 Moves the current position to the previous element; returns False if there are no more elements. More...
 
- Public Member Methods inherited from Qore::AbstractIterator
abstract auto getValue ()
 returns the current value More...
 
abstract bool next ()
 Moves the current position to the next element; returns False if there are no more elements. More...
 
abstract bool valid ()
 returns True if the iterator is currently pointing at a valid element, False if not More...
 

Detailed Description

This class defines an abstract interface for bidirectional iterators.

Member Function Documentation

◆ prev()

abstract bool Qore::AbstractBidirectionalIterator::prev ( )
pure virtual

Moves the current position to the previous element; returns False if there are no more elements.

This method will return True again after it returns False once if the object being iterated is not empty, otherwise it will always return False. The iterator object should not be used after this method returns False

Returns
False if there are no more elements (in which case the iterator object is invalid and should not be used); True if successful (meaning that the iterator object is valid)
Example:
while (i.prev()) {
printf(" + %y\n", i.getValue());
}
Note
this method is basically the opposite to AbstractIterator::next()

Implemented in Qore::HashIterator, Qore::HashListIterator, Qore::HashListReverseIterator, Qore::HashReverseIterator, Qore::ListHashIterator, Qore::ListHashReverseIterator, Qore::ListIterator, Qore::ListReverseIterator, and Qore::ObjectReverseIterator.