Class CtIterator

java.lang.Object
spoon.reflect.visitor.CtScanner
spoon.reflect.visitor.CtIterator
All Implemented Interfaces:
Iterator<CtElement>, CtVisitor

public class CtIterator extends CtScanner implements Iterator<CtElement>
A class to be able to iterate over the children elements in the tree of a given node, in depth-first order.
  • Constructor Details

    • CtIterator

      public CtIterator(CtElement root)
      CtIterator constructor, prepares the iterator from the @root node
      Parameters:
      root - the initial node to expand
  • Method Details

    • scan

      public void scan(CtElement element)
      prevent scanner from going down the tree, instead save with other CtElement children of the current node
      Overrides:
      scan in class CtScanner
      Parameters:
      element - the next direct child of the current node being expanded
    • hasNext

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

      public CtElement next()
      Dereference the "iterator"
      Specified by:
      next in interface Iterator<CtElement>
      Returns:
      CtElement the next element in DFS order without going down the tree