Module graph

Class TreeIterator

All Implemented Interfaces:
ObjectConsumer, VoidToObjectGenerator, Serializable, Cloneable, Iterable, Collection, Iterator, List, RandomAccess

public class TreeIterator extends ObjectList implements Iterator
This Iterator class iterates over all nodes of the subtree starting at a specified root node. The subtree is spanned by edges of type Graph.BRANCH_EDGE or Graph.SUCCESSOR_EDGE in forward direction.
Author:
Ole Kniemeyer
See Also:
  • Constructor Details

    • TreeIterator

      public TreeIterator()
      Create a new iterator. It has to be configured by setRoot(Node) before it is used.
    • TreeIterator

      public TreeIterator(Node root)
      Creates a new iterator iterating over the subtree starting at root.
      Parameters:
      root - the root node of the subtree
  • Method Details

    • setRoot

      public void setRoot(Node root)
      Configures this iterator to iterate over the subtree starting at root.
      Parameters:
      root - the root node of the subtree
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator
    • next

      public Object next()
      Specified by:
      next in interface Iterator
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator
    • nextNode

      public Node nextNode()
      Returns the next node of this iterator. This is equivalent to next().
      Returns:
      the next node of this iterator