Class BlossomVTree.TreeNodeIterator

  • All Implemented Interfaces:
    java.util.Iterator<BlossomVNode>
    Enclosing class:
    BlossomVTree

    public static class BlossomVTree.TreeNodeIterator
    extends java.lang.Object
    implements java.util.Iterator<BlossomVNode>
    An iterator over tree nodes. This iterator traverses the nodes of the tree in a depth-first order. Note: this iterator can also be used to iterate the nodes of some subtree of a tree.
    • Constructor Summary

      Constructors 
      Constructor Description
      TreeNodeIterator​(BlossomVNode root)
      Constructs a new TreeNodeIterator for a root.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private BlossomVNode advance()
      Advances the iterator to the next tree node
      boolean hasNext()
      BlossomVNode next()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, remove
    • Field Detail

      • currentNode

        private BlossomVNode currentNode
        The node this iterator is currently on
      • current

        private BlossomVNode current
        Variable to determine whether currentNode has been returned or not
      • treeRoot

        private BlossomVNode treeRoot
        A root of the subtree of a tree
    • Constructor Detail

      • TreeNodeIterator

        public TreeNodeIterator​(BlossomVNode root)
        Constructs a new TreeNodeIterator for a root.

        Note: root doesn't need to be a root of some tree; this iterator also works with subtrees.

        Parameters:
        root - node of a tree to start dfs traversal from.
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<BlossomVNode>
      • advance

        private BlossomVNode advance()
        Advances the iterator to the next tree node
        Returns:
        the next tree node