Qore Programming Language Reference Manual 1.17.0
|
This class an iterator class for hashes. More...
#include <QC_HashIterator.dox.h>
Public Member Methods | |
constructor (hash< auto > h) | |
Creates the hash iterator object. More... | |
constructor () | |
Creates an empty hash iterator object. More... | |
copy () | |
Creates a copy of the HashIterator object, iterating the same object as the original and in the same position. More... | |
bool | empty () |
returns True if the hash is empty; False if not More... | |
bool | first () |
returns True if on the first element of the hash More... | |
string | getKey () |
returns the current key value or throws an INVALID-ITERATOR exception if the iterator is invalid More... | |
auto | getKeyValue () |
returns the current value of the current hash key being iterated or throws an INVALID-ITERATOR exception if the iterator is invalid More... | |
auto | getValue () |
returns the current key value or throws an INVALID-ITERATOR exception if the iterator is invalid More... | |
hash< auto > | getValuePair () |
returns a hash with the current key and value (a hash with 2 keys: "key" and "value" ) or throws an INVALID-ITERATOR exception if the iterator is invalid More... | |
bool | last () |
returns True if on the last element of the hash More... | |
bool | next () |
Moves the current position to the next element in the hash; returns False if there are no more elements; if the iterator is not pointing at a valid element before this call, the iterator will be positioned on the first element in the hash if the hash is not empty. More... | |
bool | prev () |
Moves the current position to the previous element in the hash; returns False if there are no more elements; if the iterator is not pointing at a valid element before this call, the iterator will be positioned on the last element in the hash if the hash is not empty. More... | |
reset () | |
Reset the iterator instance to its initial state. More... | |
bool | valid () |
returns True if the iterator is currently pointing at a valid element, False if not More... | |
abstract bool | prev () |
Moves the current position to the previous element; returns False if there are no more elements. More... | |
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... | |
abstract bool | empty () |
returns True if the object to iterate is empty; False if not More... | |
abstract bool | first () |
returns True if on the first element More... | |
abstract bool | last () |
returns True if on the last element More... | |
This class an iterator class for hashes.
Call HashIterator::next() to iterate through the hash; do not use the iterator if HashIterator::next() returns False. A hash can be iterated in reverse order by calling HashIterator::prev() instead of HashIterator::next()
ITERATOR-THREAD-ERROR
to be thrown.Qore::HashIterator::constructor | ( | ) |
Creates an empty hash iterator object.
Qore::HashIterator::constructor | ( | hash< auto > | h | ) |
Creates the hash iterator object.
h | the hash to iterate |
Qore::HashIterator::copy | ( | ) |
Creates a copy of the HashIterator object, iterating the same object as the original and in the same position.
|
virtual |
|
virtual |
returns True if on the first element of the hash
Implements Qore::AbstractQuantifiedIterator.
Reimplemented in Qore::HashReverseIterator, and Qore::ObjectReverseIterator.
string Qore::HashIterator::getKey | ( | ) |
returns the current key 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 |
auto Qore::HashIterator::getKeyValue | ( | ) |
returns the current value of the current hash key being iterated 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 |
|
virtual |
returns the current key value or throws an INVALID-ITERATOR
exception if the iterator is invalid
The current hash key can be returned with getKey().
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.
Reimplemented in Qore::HashKeyIterator, Qore::HashKeyReverseIterator, Qore::HashPairIterator, Qore::HashPairReverseIterator, Qore::ObjectKeyIterator, Qore::ObjectKeyReverseIterator, Qore::ObjectPairIterator, and Qore::ObjectPairReverseIterator.
hash< auto > Qore::HashIterator::getValuePair | ( | ) |
returns a hash with the current key and value (a hash with 2 keys: "key"
and "value"
) or throws an INVALID-ITERATOR
exception if the iterator is invalid
"key"
and "value"
) or throws an 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 |
|
virtual |
returns True if on the last element of the hash
Implements Qore::AbstractQuantifiedIterator.
Reimplemented in Qore::HashReverseIterator, and Qore::ObjectReverseIterator.
|
virtual |
Moves the current position to the next element in the hash; returns False if there are no more elements; if the iterator is not pointing at a valid element before this call, the iterator will be positioned on the first element in the hash if the hash is not empty.
This method will return True again after it returns False once if hash is not empty, otherwise it will always return False. 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.
Reimplemented in Qore::HashReverseIterator, and Qore::ObjectReverseIterator.
|
virtual |
Moves the current position to the previous element in the hash; returns False if there are no more elements; if the iterator is not pointing at a valid element before this call, the iterator will be positioned on the last element in the hash if the hash is not empty.
This method will return True again after it returns False once if the hash is not empty, otherwise it will always return False. 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::AbstractBidirectionalIterator.
Reimplemented in Qore::HashReverseIterator, and Qore::ObjectReverseIterator.
Qore::HashIterator::reset | ( | ) |
Reset the iterator instance to its initial state.
Reset the iterator instance to its initial state
ITERATOR-THREAD-ERROR | this exception is thrown if this method is called from any thread other than the thread that created the object |
|
virtual |