Qore Programming Language Reference Manual: Qore::AbstractIterator Class Reference

Qore Programming Language Reference Manual 0.8.11

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Functions Variables Groups Pages
Public Member Functions | List of all members
Qore::AbstractIterator Class Referenceabstract

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

Inheritance diagram for Qore::AbstractIterator:
[legend]

## Public Member Functions
abstract any | 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 iterators.

Classes inheriting this class can be used to iterate abstract or complex objects with while Statements (using AbstractIterator::next()) or directly in the following language constructs:

- Map Operator (map)
- Fold Right Operator (foldr) and Fold Left Operator (foldl)
- Select From List Operator (select)
- foreach Statements

## Member Function Documentation

abstract any Qore::AbstractIterator::getValue | ( |  | ) |
| pure virtual

returns the current value

Returns
  the current value

Example:
  while ($i.next()) {
  printf("+ %y\n", $i.getValue());
  }

Exceptions

  INVALID-ITERATOR | the iterator is not pointing at a valid element

See Also
  AbstractIterator::valid()

Implemented in Qore::SQL::SQLStatement, Qore::HashListIterator, Qore::HashIterator, Qore::ListHashIterator, Qore::FileLineIterator, Qore::ListIterator, Qore::ObjectPairReverseIterator, Qore::ObjectKeyReverseIterator, Qore::HashKeyReverseIterator, Qore::HashPairReverseIterator, Qore::ObjectPairIterator, Qore::ObjectKeyIterator, Qore::HashPairIterator, Qore::HashKeyIterator, Qore::RangeIterator, and Qore::SingleValueIterator.

abstract bool Qore::AbstractIterator::next | ( |  | ) |
| pure virtual

Moves the current position to the next 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.next()) {
  printf(" + %y\n", $i.getValue());
  }

Implemented in Qore::SQL::SQLStatement, Qore::HashListIterator, Qore::ListHashIterator, Qore::HashIterator, Qore::FileLineIterator, Qore::ListIterator, Qore::HashListReverseIterator, Qore::ListHashReverseIterator, Qore::ObjectReverseIterator, Qore::HashReverseIterator, Qore::ListReverseIterator, Qore::RangeIterator, and Qore::SingleValueIterator.

abstract bool Qore::AbstractIterator::valid | ( |  | ) |
| pure virtual

returns True if the iterator is currently pointing at a valid element, False if not

Returns
  True if the iterator is currently pointing at a valid element, False if not

Example:
  if ($i.valid())
  printf("current value: %y\n", $i.getValue());

Implemented in Qore::SQL::SQLStatement, Qore::HashListIterator, Qore::ListHashIterator, Qore::HashIterator, Qore::ListIterator, Qore::FileLineIterator, Qore::RangeIterator, and Qore::SingleValueIterator.