@Beta @GwtCompatible(emulated=true) public abstract class TreeTraverser<T> extends Object
T
as nodes in a tree, and provides methods to traverse the trees induced by this traverser.
For example, the tree
h / | \ / e \ d g /|\ | / | \ f a b c
can be iterated over in preorder (hdabcegf), postorder (abcdefgh), or breadth-first order (hdegabcf).
Null nodes are strictly forbidden.
Constructor and Description |
---|
TreeTraverser()
|
Modifier and Type | Method and Description |
---|---|
FluentIterable |
breadthFirstTraversal(T root)
Returns an unmodifiable iterable over the nodes in a tree structure, using breadth-first traversal.
|
abstract Iterable |
children(T root)
Returns the children of the specified node.
|
FluentIterable |
postOrderTraversal(T root)
Returns an unmodifiable iterable over the nodes in a tree structure, using post-order traversal.
|
FluentIterable |
preOrderTraversal(T root)
Returns an unmodifiable iterable over the nodes in a tree structure, using pre-order traversal.
|
public abstract Iterable<T> children(T root)
public final FluentIterable<T> preOrderTraversal(T root)
No guarantees are made about the behavior of the traversal when nodes change while iteration is in progress or when the iterators generated by children(T)
are advanced.
public final FluentIterable<T> postOrderTraversal(T root)
No guarantees are made about the behavior of the traversal when nodes change while iteration is in progress or when the iterators generated by children(T)
are advanced.
public final FluentIterable<T> breadthFirstTraversal(T root)
No guarantees are made about the behavior of the traversal when nodes change while iteration is in progress or when the iterators generated by children(T)
are advanced.