Package com.google.common.collect
Class BinaryTreeTraverser<T>
- java.lang.Object
-
- com.google.common.collect.TreeTraverser<T>
-
- com.google.common.collect.BinaryTreeTraverser<T>
-
@Beta @GwtCompatible public abstract class BinaryTreeTraverser<T> extends TreeTraverser<T>
A variant ofTreeTraverserfor binary trees, providing additional traversals specific to binary trees.- Since:
- 15.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classBinaryTreeTraverser.InOrderIteratorprivate classBinaryTreeTraverser.PostOrderIteratorprivate classBinaryTreeTraverser.PreOrderIterator
-
Constructor Summary
Constructors Constructor Description BinaryTreeTraverser()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Iterable<T>children(T root)Returns the children of this node, in left-to-right order.FluentIterable<T>inOrderTraversal(T root)abstract Optional<T>leftChild(T root)Returns the left child of the specified node, orOptional.absent()if the specified node has no left child.(package private) UnmodifiableIterator<T>postOrderIterator(T root)(package private) UnmodifiableIterator<T>preOrderIterator(T root)private static <T> voidpushIfPresent(java.util.Deque<T> stack, Optional<T> node)abstract Optional<T>rightChild(T root)Returns the right child of the specified node, orOptional.absent()if the specified node has no right child.-
Methods inherited from class com.google.common.collect.TreeTraverser
breadthFirstTraversal, postOrderTraversal, preOrderTraversal, using
-
-
-
-
Method Detail
-
leftChild
public abstract Optional<T> leftChild(T root)
Returns the left child of the specified node, orOptional.absent()if the specified node has no left child.
-
rightChild
public abstract Optional<T> rightChild(T root)
Returns the right child of the specified node, orOptional.absent()if the specified node has no right child.
-
children
public final java.lang.Iterable<T> children(T root)
Returns the children of this node, in left-to-right order.- Specified by:
childrenin classTreeTraverser<T>
-
preOrderIterator
UnmodifiableIterator<T> preOrderIterator(T root)
- Overrides:
preOrderIteratorin classTreeTraverser<T>
-
postOrderIterator
UnmodifiableIterator<T> postOrderIterator(T root)
- Overrides:
postOrderIteratorin classTreeTraverser<T>
-
inOrderTraversal
public final FluentIterable<T> inOrderTraversal(T root)
-
pushIfPresent
private static <T> void pushIfPresent(java.util.Deque<T> stack, Optional<T> node)
-
-