|
| constructor (softlist< auto > l) |
| Creates the list hash iterator object.
|
|
| copy () |
| Creates a copy of the ListHashReverseIterator object, iterating the same object as the original and in the same position.
|
|
bool | first () |
| returns True if on the first element being iterated (ie the last element in the list)
|
|
bool | last () |
| returns True if on the last element being iterated (ie the first element in the list)
|
|
auto | memberGate (string key) |
| This method allows the iterator to be dereferenced directly as a hash for the current row being iterated, as memberGate methods are called implicitly when an unknown member is accessed from outside the class.
|
|
bool | next () |
| Moves the current position to the next element in the result list; 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 list if the list is not empty.
|
|
bool | prev () |
| Moves the current position to the previous element in the result list; 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 list if the list is not empty.
|
|
| constructor (softlist< auto > l) |
| Creates the hash list iterator object.
|
|
| copy () |
| Creates a copy of the ListHashIterator object, iterating the same object as the original and in the same position.
|
|
bool | empty () |
| returns True if the result list is empty; False if not
|
|
bool | first () |
| returns True if on the first element of the list
|
|
auto | getKeyValue (string key) |
| Returns the current value for the column given as an argument.
|
|
hash< auto > | getRow () |
| returns the current row value as a hash or throws an INVALID-ITERATOR exception if the iterator is invalid
|
|
hash< auto > | getValue () |
| returns the current row value as a hash or throws an INVALID-ITERATOR exception if the iterator is invalid
|
|
int | index () |
| returns the current iterator position in the list or -1 if not pointing at a valid element
|
|
bool | last () |
| returns True if on the last element of the list
|
|
int | max () |
| returns the number of elements in the list
|
|
auto | memberGate (string key) |
| This method allows the iterator to be dereferenced directly as a hash for the current row being iterated, as memberGate methods are called implicitly when an unknown member is accessed from outside the class.
|
|
bool | next () |
| Moves the current position to the next element in the result list; 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 list if the list is not empty.
|
|
bool | prev () |
| Moves the current position to the previous element in the result list; 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 list if the list is not empty.
|
|
| reset () |
| Reset the iterator instance to its initial state.
|
|
bool | set (int pos) |
| sets the new position in the result list; if the position is invalid then the method returns False, meaning the iterator is not valid, otherwise it returns True
|
|
bool | valid () |
| returns True if the iterator is currently pointing at a valid element, False if not
|
|
abstract bool | prev () |
| Moves the current position to the previous element; returns False if there are no more elements.
|
|
abstract auto | getValue () |
| returns the current value
|
|
abstract bool | next () |
| Moves the current position to the next element; returns False if there are no more elements.
|
|
abstract bool | valid () |
| returns True if the iterator is currently pointing at a valid element, False if not
|
|
abstract bool | empty () |
| returns True if the object to iterate is empty; False if not
|
|
abstract bool | first () |
| returns True if on the first element
|
|
abstract bool | last () |
| returns True if on the last element
|
|
This class a reverse iterator class for lists of hashes as returned by Qore::SQL::Datasource::selectRows() and Qore::SQL::DatasourcePool::selectRows(), both of which return hashes with keys giving column names where the key values are lists of column values.
Call ListHashReverseIterator::next() to iterate through the lists of column values assigned to each hash key in reverse order; do not use the iterator if ListHashReverseIterator::next() returns False. A result list can be iterated in reverse order by calling ListHashReverseIterator::prev() instead of ListHashReverseIterator::next()
- Example: ListHashReverseIterator basic usage
list<auto> data = (
( "column1" : 1, "column2" : "a"),
( "column1" : 2, "column2" : "b"),
);
ListHashReverseIterator it(data);
while (it.next()) {
printf("iter %d: %n\n", it.index(), it.getValue());
}
iter 1: hash: (column1 : 2, column2 : "b")
iter 0: hash: (column1 : 1, column2 : "a")
- Note
-
- See also
- ListHashIterator