Class CtBFSIterator

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

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

    • CtBFSIterator

      public CtBFSIterator(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 BFS order without going down the tree