This class an iterator class for hashes.
More...
|
| | constructor (hash h) |
| | Creates the hash iterator object. More...
|
| |
| | constructor () |
| | Creates an empty iterator object. More...
|
| |
| | copy () |
| | Creates a copy of the HashPairReverseIterator object, iterating the same object as the original and in the same position. More...
|
| |
| string | getValue () |
| | 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...
|
| |
| | constructor (hash h) |
| | Creates the hash iterator object. More...
|
| |
| | constructor () |
| | Creates an empty iterator object. More...
|
| |
| | copy () |
| | Creates a copy of the HashReverseIterator object, iterating the same object as the original and in the same position. More...
|
| |
| bool | first () |
| | returns True if on the last element of the hash More...
|
| |
| bool | last () |
| | returns True if on the first element of the hash More...
|
| |
| bool | next () |
| | 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...
|
| |
| bool | prev () |
| | 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...
|
| |
| | constructor (hash 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...
|
| |
| 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...
|
| |
| hash | 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...
|
| |
| | 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...
|
| |
This class an iterator class for hashes.
Call HashPairReverseIterator::next() to iterate through the hash in reverse order; do not use the iterator if HashPairReverseIterator::next() returns False. A hash can be iterated in reverse order by calling HashPairReverseIterator::prev() instead of HashPairReverseIterator::next()
- Example: HashPairReverseIterator basic usage
7 HashPairReverseIterator it(data);
9 printf(
"iter: %n\n", it.getValue());
12 iter: hash: (key :
"key3", value : 3)
13 iter: hash: (key :
"key2", value : 2)
14 iter: hash: (key :
"key1", value : 1)
- Note
-
- See Also
- HashPairIterator
| Qore::HashPairReverseIterator::constructor |
( |
hash |
h | ) |
|
Creates the hash iterator object.
- Parameters
-
- Example:
1 HashPairReverseIterator hi(h);
| Qore::HashPairReverseIterator::constructor |
( |
| ) |
|
Creates an empty iterator object.
- Example:
1 *hash h = get_hash_or_nothing();
2 HashPairReverseIterator hi(h);
| Qore::HashPairReverseIterator::copy |
( |
| ) |
|
Creates a copy of the HashPairReverseIterator object, iterating the same object as the original and in the same position.
- Example:
1 HashPairReverseIterator ni = i.copy();
| string Qore::HashPairReverseIterator::getValue |
( |
| ) |
|
|
virtual |
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
- 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
- Code Flags:
- RET_VALUE_ONLY
- Example:
1 map
printf(
"%s: %y\n", $1.key, $1.value), hash.pairIterator();
- Exceptions
-
| INVALID-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 |
- Since
- Qore 0.8.6.2
Reimplemented from Qore::HashIterator.