Class TreeFilterIterator<T>

  • All Implemented Interfaces:
    Iterator<T>

    public final class TreeFilterIterator<T>
    extends Object
    implements Iterator<T>
    Iterator that uses condition to filter out complete sub-tree. For a tree:
       NodeA
         |
         o NodeB
         |   |
         |   o NodeC
         |
         o NodeD
     
    and condition endsWith("B"), this iterator would yield {NodeA, NodeD}, i.e. completely throwing away NodeB and its sub-tree.

    Note, unlike FilterIterator, satisfied condition means element will be abandoned.

    • Constructor Detail

      • TreeFilterIterator

        public TreeFilterIterator​(@NotNull
                                  TreeIterator<T> iterator,
                                  @NotNull
                                  Condition<T> skipCondition)
        Parameters:
        iterator - source of nodes
        skipCondition - when condition is met, subtree is abandoned
    • Method Detail

      • hasNext

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

        public T next()
        Specified by:
        next in interface Iterator<T>
      • remove

        public void remove()
        Specified by:
        remove in interface Iterator<T>