NETJVM 

The Iterator-ID Paragraph

The Iterator-ID paragraph indicates that this Identification Division introduces an iterator definition and specifies the name that identifies the iterator. Iterator-id can be specified wherever Method-ID can be specified, and can be used to define either static or instance iterators.

General Format

Iterator-ID

Syntax Rules:

  1. The procedure division header of an Iterator must include a Yielding phrase. The type of the item specified in the Yielding phrase determines the type of the iterators.
  2. Attribute-clause is defined in the topic on the Attribute, Custom-Attribute Clause.

General Rules

  1. For an iterators of type T, the system will automatically generate a nested class which implements both IEnumerable[T] and IEnumerator[T].
  2. The system also generates a method with the name specified in the Iterator-ID paragraph. This method returns an item of the nested type defined in GR 1.
  3. Code outside the context of the iterators may invoke this method to return the iteration object, and iterate through it using the PERFORM THROUGH collection class syntax (see PERFORM statement format 5).
  4. The order in which iteration proceeds is determined by the successive RETURNING values when each EXIT ITERATOR statement is executed.