T
- public class BinaryTreeNL<T> extends BinaryTreeSecondary<T>
BinaryTree
implemented as a recursive data structure, not layered on
any other components. The NL
in BinaryTreeNL
conveys that
this is a Non-Layered implementation.Constructor and Description |
---|
BinaryTreeNL() |
Modifier and Type | Method and Description |
---|---|
void |
build(T root,
BinaryTree<T> left,
BinaryTree<T> right)
Builds
this into a Binary Tree with root as the root of
the tree, left as the left subtree of this , and right as the right subtree of this . |
void |
clear()
Resets
this to its initial value. |
int |
height()
Reports the height of
this . |
BinaryTreeNL<T> |
leftSubtree()
Removes the left subtree from
this and returns it. |
BinaryTreeNL<T> |
newInstance()
Returns a new object with the same dynamic type as
this , having
an initial value. |
BinaryTreeNL<T> |
rightSubtree()
Removes the right subtree from
this and returns it. |
T |
root()
Returns a reference to the root of
this . |
int |
size()
Reports the number of nodes int
this . |
void |
transferFrom(BinaryTree<T> source)
Sets
this to the incoming value of source, and resets
source to an initial value; the declaration notwithstanding, the
dynamic type of source must be the same as the dynamic type of
this . |
contains, equals, remove, replaceRoot, toString
public void build(T root, BinaryTree<T> left, BinaryTree<T> right)
BinaryTreeKernel
this
into a Binary Tree with root
as the root of
the tree, left
as the left subtree of this
, and right
as the right subtree of this
.root
- the new root of this
left
- the new left subtree of this
right
- the new right subtree of this
public BinaryTreeNL<T> leftSubtree()
BinaryTreeKernel
this
and returns it.public BinaryTreeNL<T> rightSubtree()
BinaryTreeKernel
this
and returns it.public T root()
BinaryTreeKernel
this
.public int size()
BinaryTreeKernel
this
.public void clear()
Standard
this
to its initial value.public void transferFrom(BinaryTree<T> source)
Standard
this
to the incoming value of source, and resets
source
to an initial value; the declaration notwithstanding, the
dynamic type of source
must be the same as the dynamic type of
this
. If the type T has a no-argument constructor, then
source
satisfies the contract of the no-argument constructor for
T. If T does not have a no-argument constructor, then source satisfies
the contract of the constructor call that was used to initialize
#source
.source
- object whose value is to be transferredpublic BinaryTreeNL<T> newInstance()
Standard
this
, having
an initial value. If the type T has a no-argument constructor, then the
value of the new returned object satisfies the contract of the
no-argument constructor for T. If T does not have a no-argument
constructor, then the value of the new returned object satisfies the
contract of the constructor call that was used to initialize
this
.this
with an initial valuepublic int height()
BinaryTreeKernel
this
.this