Skip to main content

AbstractIterator

Short summary

An abstract class to implement most basic iterator functions for use in custom Iterators. Users still need to implement iterate and hasNext, as these depend on the data-stucture. Iterate should take care to assign THIS^.current in their iterate implementation.

AccessAbstractFinalExtendsImplements
YesNoCNM_AbstractObject.ObjectCNM_CollectionInterfaces.IIterator

UML Diagram

Parameters

none

Properties

current

Type: CNM_AbstractObject.IObject

This property returns the current element which the iterator points to.

Methods

getNext

This method returns the next object from the iterator and move the iterator to it.

moveNext

  • Return type: BOOL

This method returns true if there exists another element to iterate to and fetches the next element to THIS^.current.

reset

  • Return type: VOID

This method resets the iterator.

Abstract methods

hasNext

  • Return type: BOOL

This method returns if there exists another element to iterate to.

iterate

This method delivers the next object from the collection and returns the current state of iteration.

Code

Declaration

FUNCTION_BLOCK ABSTRACT AbstractIterator EXTENDS CNM_AbstractObject.Object IMPLEMENTS CNM_CollectionInterfaces.IIterator
VAR
{attribute 'no_copy'}
currentObject :CNM_AbstractObject.IObject;
END_VAR