public class BinaryTree extends Tree
Tree
s.
Every BinaryTree
can be a root itself, can contain one or no content
object and none, one or two
additional Tree
objects.
These can be any Tree
objects and do not have to be BinaryTree
objects.Constructor and Description |
---|
BinaryTree()
Creates an empty BinaryTree.
|
BinaryTree(List treeList)
Deprecated.
Why would anyone want to create a
BinaryTree from a List ?! Just use any other
constructor. |
BinaryTree(Tree leftTree,
Tree rightTree)
Creates a
BinaryTree and sets the left and right tree. |
BinaryTree(Tree leftTree,
Tree rightTree,
java.lang.Object content)
Creates a
BinaryTree and sets the left and right tree. |
Modifier and Type | Method and Description |
---|---|
void |
addTree(Tree t)
Deprecated.
use setLeftTree/setRightTree/getLeftTree/getRightTree instead.
|
java.lang.Object |
getContent()
Returns the stored object.
|
Tree |
getLeftTree() |
Tree |
getRightTree() |
int |
getSubTreeCount()
Returns the amount of non-null tree objects in the
BinaryTree . |
Tree |
getTree(int index)
Returns the
Tree with the specified index, starting from 0. |
void |
removeTree(int index)
Deprecated.
use setLeftTree/setRightTree/getLeftTree/getRightTree instead.
|
void |
setContent(java.lang.Object content)
Sets an object into the Tree's content storage.
|
void |
setLeftTree(Tree leftTree) |
void |
setRightTree(Tree rightTree) |
public BinaryTree()
public BinaryTree(Tree leftTree, Tree rightTree)
BinaryTree
and sets the left and right tree. Contents may be null.leftTree
- the Tree object to go in the leftTree storage.rightTree
- the Tree object to go in the rightTree storage.public BinaryTree(Tree leftTree, Tree rightTree, java.lang.Object content)
BinaryTree
and sets the left and right tree. Contents may be null.leftTree
- the Tree object to go in the leftTree storage.rightTree
- the Tree object to go in the rightTree storage.content
- any object of any type.@Deprecated public BinaryTree(List treeList)
BinaryTree
from a List
?! Just use any other
constructor.BinaryTree
from the first two objects of treeList and sets them as leftTree and rightTree,
respectively.
Exists only because the normal Tree
can be created with a child list as well.treeList
- a list of Tree objects.public Tree getLeftTree()
public void setLeftTree(Tree leftTree)
public Tree getRightTree()
public void setRightTree(Tree rightTree)
public Tree getTree(int index)
Tree
with the specified index, starting from 0.public java.lang.Object getContent()
getContent
in class Tree
public void setContent(java.lang.Object content)
setContent
in class Tree
content
- any object of any type. May be null.@Deprecated public void addTree(Tree t)
@Deprecated public void removeTree(int index)
removeTree
in class Tree
index
- the index of nothing, because this shouldn't be used.public int getSubTreeCount()
BinaryTree
.
This can be either 0, 1 or 2.getSubTreeCount
in class Tree
BinaryTree
.