public class Tree<T> extends Object implements Traverse.Traversable<Tree<T>>
| 限定符和类型 | 方法和说明 |
|---|---|
Tree<T> |
add(T value)
Add the value as child
|
Tree<T> |
add(Tree<T> node)
Add the node as child
|
Optional<Tree<T>> |
commonParent(Tree<T> other)
Get the first common parent of this node and the given node
|
Optional<Tree<T>> |
deepChild(T value)
Get the first matched child with the given value from all of the sub-tree
|
Optional<Tree<T>> |
deepChild(Tree<T> node)
Get the first matched child with the given value from all of the sub-tree
|
Optional<Tree<T>> |
getChild(T value)
Get the first matched child with the given value from children
|
Optional<Tree<T>> |
getChild(Tree<T> node)
Return the given node if it's this node's child
|
List<Tree<T>> |
getChildren() |
Tree<T> |
getParent() |
T |
getValue() |
boolean |
hasChild(T value)
Returns true if there is a child's value is the given value
|
boolean |
isLeaf()
Returns true if the node has no children.
|
io.reactivex.Flowable<Tree<T>> |
parents()
Get all of the node's parent
|
Optional<io.reactivex.Flowable<Tree<T>>> |
pathTo(Tree<T> node) |
boolean |
remove(T value)
Remove the first matched node with given value from children
|
boolean |
remove(Tree<T> node)
Remove the node from children
|
Optional<Tree<T>> |
removeFromParent()
Remove this node from its parent
|
void |
rotateAsParent() |
void |
swap(Tree<T> node)
Swap with the given node.
|
String |
toString() |
io.reactivex.Flowable<Tree<T>> |
traverse(Traverse.Traverser traverser) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbreadthFirstTraversal, defaultTraverser, iterator, iterator, postOrderTraversal, preOrderTraversalforEach, spliteratorpublic Tree(T value)
public T getValue()
public boolean remove(T value)
value - public Optional<Tree<T>> removeFromParent()
public boolean hasChild(T value)
value - public boolean isLeaf()
public Optional<Tree<T>> getChild(T value)
value - public Optional<Tree<T>> getChild(Tree<T> node)
node - public Optional<Tree<T>> deepChild(T value)
value - public Optional<Tree<T>> deepChild(Tree<T> node)
node - public Optional<Tree<T>> commonParent(Tree<T> other)
other - public void swap(Tree<T> node)
node - public void rotateAsParent()
public io.reactivex.Flowable<Tree<T>> traverse(Traverse.Traverser traverser)
traverse 在接口中 Traverse.Traversable<Tree<T>>Copyright © 2018. All rights reserved.