T
- public interface BinaryTree<T> extends BinaryTreeKernel<T>
BinaryTreeKernel
interface. All method implementations must, by
design, use only the BinaryTreeKernel methods to perform operations on the
component.Modifier and Type | Method and Description |
---|---|
boolean |
contains(T node)
Reports whether
node is in this . |
void |
remove(T node)
Searches
this for node , and removes it from this . |
T |
replaceRoot(T replacement)
Swaps
#this.root with replacement and returns
#this.root . |
build, height, leftSubtree, rightSubtree, root, size
clear, newInstance, transferFrom
T replaceRoot(T replacement)
#this.root
with replacement
and returns
#this.root
.replacement
- new root of this
void remove(T node)
this
for node
, and removes it from this
.
The binary tree represented by this
is restructured such that the
left-most node of the right subtree of the binary tree rooted at
node
is moved to the root of that subtree. If there is no right
subtree, then the right-most node of the left subtree of the binary tree
rooted at node
is moved to the root of that subtree. In the case
that node
is a leaf, it is simply removed.node
- node to be removed from thisthis
is restructured
such that the left-most node of the right subtree of the binary
tree rooted at node
is moved to the root of that
subtree. If there is no right subtree, then the right-most node
of the left subtree of the binary tree rooted at node
is
moved to the root of that subtree. In the case that node
is a leaf, it is simply removed]boolean contains(T node)
node
is in this
.node
- node to search for