All Classes Namespaces Functions Variables Groups Pages
Qore::ObjectPairReverseIterator Class Reference

This class an iterator class for objects. More...

Inheritance diagram for Qore::ObjectPairReverseIterator:
[legend]

## Public Member Functions

| constructor (object o)
| Creates the object iterator object.
| constructor ()
| Creates an empty iterator object.
| copy ()
| Creates a copy of the ObjectPairReverseIterator object, iterating the same object as the original and in the same position.
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
Public Member Functions inherited from Qore::ObjectReverseIterator
| constructor (object o)
| Creates the object iterator object.
| constructor ()
| Creates an empty iterator object.
| copy ()
| Creates a copy of the ObjectReverseIterator object, iterating the same object as the original and in the same position.
bool | first ()
| returns True if on the last element of the object
bool | last ()
| returns True if on the first element of the object
bool | next ()
| Moves the current position to the previous element in the object; 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 object if the object is not empty.
bool | prev ()
| Moves the current position to the next element in the object; 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 object if the object is not empty.
Public Member Functions inherited from Qore::ObjectIterator
| constructor (object o)
| Creates the object iterator object.
| constructor ()
| Creates an empty object iterator object.
| copy ()
| Creates a copy of the ObjectIterator object, iterating the same object as the original and in the same position.
Public Member Functions inherited from Qore::HashIterator
| constructor (hash h)
| Creates the hash iterator object.
| constructor ()
| Creates an empty hash iterator object.
| copy ()
| Creates a copy of the HashIterator object, iterating the same object as the original and in the same position.
bool | empty ()
| returns True if the hash is empty; False if not
string | getKey ()
| returns the current key value or throws an `INVALID-ITERATOR` exception if the iterator is invalid
any | getKeyValue ()
| returns the current value of the current has key being iterated or throws an `INVALID-ITERATOR` exception if the iterator is invalid
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
| reset ()
| Reset the iterator instance to its initial state.
bool | valid ()
| returns True if the iterator is currently pointing at a valid element, False if not

## Detailed Description

This class an iterator class for objects.

Call ObjectPairReverseIterator::next() to iterate through the object in reverse order; do not use the iterator if ObjectPairReverseIterator::next() returns False. A object can be iterated in reverse order by calling ObjectPairReverseIterator::prev() instead of ObjectPairReverseIterator::next()

Note
  - In general, the ObjectPairReverseIterator class is not designed to be accessed from multiple threads; it was created without locking for fast and efficient use when used from a single thread. For methods that would be unsafe to use in another thread, any use of such methods in threads other than the thread where the constructor was called will cause an `ITERATOR-THREAD-ERROR` to be thrown.
  - ObjectPairReverseIterator is functionally equivalent to ObjectPairIterator, but the effect of ObjectPairReverseIterator::next() and ObjectPairReverseIterator::prev() are the opposite of ObjectPairIterator::next() and ObjectPairIterator::prev(); that is ObjectPairReverseIterator::next() will iterate through the object in reverse order, while ObjectPairReverseIterator::prev() iterates in forward order. Additionally the meanings of the return values for ObjectPairReverseIterator::first() and ObjectPairReverseIterator::last() are swapped in respect to ObjectPairIterator::first() and ObjectPairIterator::last().

See Also
  ObjectPairIterator

## Member Function Documentation

Qore::ObjectPairReverseIterator::constructor | ( | object | o | ) |

Creates the object iterator object.

Parameters

  o | the object to iterate

Example:
  my ObjectPairReverseIterator $i($obj);

Qore::ObjectPairReverseIterator::constructor | ( |  | ) |

Creates an empty iterator object.

Example:
  my *object $obj = get_object_or_nothing();
  my ObjectPairReverseIterator $i($obj);

Qore::ObjectPairReverseIterator::copy | ( |  | ) |

Creates a copy of the ObjectPairReverseIterator object, iterating the same object as the original and in the same position.

Example:
  my ObjectPairReverseIterator $ni = $i.copy();

string Qore::ObjectPairReverseIterator::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:
  foreach my hash $h in (new ObjectPairReverseIterator($obj))
  printf("%s: %y\n", $h.key, $h.value);

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.