Class FOR_ListIterator

java.lang.Object
simula.runtime.FOR_ListIterator
All Implemented Interfaces:
Iterator<Boolean>

public final class FOR_ListIterator extends Object implements Iterator<Boolean>

The Implementation of the for-statement is a bit tricky. The basic idea is to create a ForList iterator that iterates over a set of ForElt iterators. The following subclasses of ForElt are defined:

Each of which has a boolean method 'hasNext' indicating whether this for-element is exhausted. All parameters to these classes are transferred 'by name'. This is done to ensure that all expressions are evaluated in the right order. The assignment to the 'control variable' is done within the various for-elements when the 'next' method is invoked.

Simula for-statement for-list iterator

  • Field Details

    • forElt

      final FOR_Element[] forElt
      The ForElt array.
    • index

      int index
      Current index into the ForElt array.
  • Constructor Details

    • FOR_ListIterator

      public FOR_ListIterator(FOR_Element... forElt)
      Create a ForListIterator consisting of an array of ForElt Iterators.
      Parameters:
      forElt - an array of ForElt Iterators.
  • Method Details

    • hasNext

      public boolean hasNext()
      Returns true if the iteration has more elements.
      Specified by:
      hasNext in interface Iterator<Boolean>
      Returns:
      true if the iteration has more elements
    • next

      public Boolean next()
      Update the control variable with the next value if any.
      Specified by:
      next in interface Iterator<Boolean>
      Returns:
      true if the control variable was updated; otherwise false.