T
- public class BinaryTreeImpl<T extends Comparable<T>> extends Object implements BinaryTree<T>
DLR_ORDER, LDR_ORDER, LRD_ORDER
Constructor and Description |
---|
BinaryTreeImpl(T data)
构造函数
|
Modifier and Type | Method and Description |
---|---|
BinaryTree<T> |
add(T object)
添加新结点 返回所添加的结点
|
int |
compare(T a,
T b) |
void |
foreach(Processor<T> process)
默认采用中序
|
void |
foreach(Processor<T> process,
int mode)
用指定的遍历方式对每个结点执行操作 mode: 0:中序遍历 -1:前序遍历 1:后序遍历
|
T |
getData()
获取结点数据
|
BinaryTreeImpl<T> |
getParent() |
int |
height()
获取树的高度
|
void |
remove(T o)
删除指定结点子树
|
BinaryTree<T> |
search(T find)
查找指定结点
|
int |
size()
获取树的结点个数
|
void |
swap()
左右子树对调
|
AVLTree<T> |
toAVLTree()
转换成平衡二叉树
|
public BinaryTreeImpl(T data)
data
- CompareException
public BinaryTree<T> search(T find)
search
in interface BinaryTree<T extends Comparable<T>>
find
- public BinaryTree<T> add(T object)
add
in interface BinaryTree<T extends Comparable<T>>
object
- public T getData()
getData
in interface BinaryTree<T extends Comparable<T>>
public void swap()
public void remove(T o)
remove
in interface BinaryTree<T extends Comparable<T>>
o
- public void foreach(Processor<T> process)
foreach
in interface BinaryTree<T extends Comparable<T>>
public void foreach(Processor<T> process, int mode)
foreach
in interface BinaryTree<T extends Comparable<T>>
process
- mode
- public int size()
size
in interface BinaryTree<T extends Comparable<T>>
public int height()
height
in interface BinaryTree<T extends Comparable<T>>
public AVLTree<T> toAVLTree()
toAVLTree
in interface BinaryTree<T extends Comparable<T>>
public BinaryTreeImpl<T> getParent()
getParent
in interface BinaryTree<T extends Comparable<T>>
Copyright © 2006–2018 TinyGroup. All rights reserved.