Class NodeIterator

    • Constructor Detail

      • NodeIterator

        public NodeIterator​(Node firstNode)
        Parameters:
        firstNode - node from which to start the iteration and continue until all sibling nodes have been traversed
      • NodeIterator

        public NodeIterator​(Node firstNode,
                            boolean reversed)
        Parameters:
        firstNode - node from which to start the iteration and continue until all sibling nodes have been traversed
        reversed - true/false if the nodes are to be traversed in reverse order. If true the nodes previous sibling will be used instead of next sibling
      • NodeIterator

        public NodeIterator​(Node firstNode,
                            Node lastNode)
        Parameters:
        firstNode - node from which to start the iteration and continue until all sibling nodes have been traversed or lastNode has been traversed
        lastNode - the last node to be traversed
      • NodeIterator

        public NodeIterator​(Node firstNode,
                            Node lastNode,
                            boolean reversed)
        iterate nodes until null or last node is iterated over
        Parameters:
        firstNode - node from which to start the iteration and continue until all sibling nodes have been traversed or lastNode has been traversed
        lastNode - the last node to be traversed
        reversed - true/false if the nodes are to be traversed in reverse order. If true the nodes previous sibling will be used instead of next sibling
    • Method Detail

      • isReversed

        public boolean isReversed()
        Specified by:
        isReversed in interface ReversibleIterator<Node>
        Returns:
        true if the iterator is a reversed iterator
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<Node>
        Returns:
        true if there is a next node
      • next

        public Node next()
        Specified by:
        next in interface java.util.Iterator<Node>
        Returns:
        the next node for the iterator. If the iterator is not reversed then the previous node's next sibling is returned. If it is reversed the the previous node's previous sibling is returned.
      • remove

        public void remove()
        Remove the last node returned by next()
        Specified by:
        remove in interface java.util.Iterator<Node>
      • forEachRemaining

        public void forEachRemaining​(java.util.function.Consumer<? super Node> consumer)
        Specified by:
        forEachRemaining in interface java.util.Iterator<Node>