T
- public abstract class BinaryTreeSecondary<T> extends java.lang.Object implements BinaryTree<T>
BinaryTree
interface, as well as the
implementation for equals
, toString
, and hashCode
methods.Constructor and Description |
---|
BinaryTreeSecondary() |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(T node)
Reports whether
node is in this . |
boolean |
equals(java.lang.Object o) |
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 . |
java.lang.String |
toString() |
getClass, hashCode, notify, notifyAll, wait, wait, wait
build, height, leftSubtree, rightSubtree, root, size
clear, newInstance, transferFrom
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public T replaceRoot(T replacement)
BinaryTree
#this.root
with replacement
and returns
#this.root
.replaceRoot
in interface BinaryTree<T>
replacement
- new root of this
public boolean contains(T node)
BinaryTree
node
is in this
.contains
in interface BinaryTree<T>
node
- node to search forpublic void remove(T node)
BinaryTree
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.remove
in interface BinaryTree<T>
node
- node to be removed from this