E
- the type of elements in this treepublic class BinaryTree<E> extends OrderedTree<E>
PAREN_END, PAREN_START
Constructor and Description |
---|
BinaryTree()
Public constructor.
|
BinaryTree(E element)
Public constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(BinaryTree<E> child)
Adds the given child to this node.
|
void |
addChild(BinaryTree<E> child)
Adds the given child to this node.
|
void |
addChild(E element)
Adds a child with the given element to this node.
|
BinaryTree<E> |
find(E element)
Finds a node of the first occurrence of the given element in this tree.
|
BinaryTree<E> |
findChild(E element)
Finds a child of the first occurrence of the given element in this node.
|
java.util.List<BinaryTree<E>> |
getBinaryTreeNodes()
Returns a list of all nodes of the type
BinaryTree<E> in this tree. |
BinaryTree<E> |
getChildAt(int index)
Returns the child of this node at the given index.
|
BinaryTree<E> |
getDeepestLeftLeaf()
Returns the deepest left leaf node of this tree.
|
BinaryTree<E> |
getDeepestRightLeaf()
Returns the deepest right leaf node of this tree.
|
BinaryTree<E> |
getLeftChild()
Returns the left child of this node.
|
BinaryTree<E> |
getParent()
Returns the parent of this node.
|
BinaryTree<E> |
getRightChild()
Returns the right child of this node.
|
boolean |
hasLeftChild()
Returns
true if this node has a left child. |
boolean |
hasLeftChild(BinaryTree<E> child)
Returns
true if this node has the given left child. |
boolean |
hasLeftChild(E element)
Returns
true if this node has a left child with the given element. |
boolean |
hasRightChild()
Returns
true if this node has a right child. |
boolean |
hasRightChild(BinaryTree<E> child)
Returns
true if this node has the given right child. |
boolean |
hasRightChild(E element)
Returns
true if this node has a right child with the given element. |
int |
numChildren()
Returns the number of children of this node.
|
void |
removeLeftChild()
Removes the left child of this node.
|
void |
removeRightChild()
Removes the right child of this node.
|
void |
setLeftChild(BinaryTree<E> child)
Sets the given left child to this node.
|
void |
setLeftChild(E element)
Sets the left child of this child with the given element.
|
void |
setParent(BinaryTree<E> parent)
Sets the given parent to this node.
|
void |
setRightChild(BinaryTree<E> child)
Sets the given right child to this node.
|
void |
setRightChild(E element)
Sets the right child of this node with the given element.
|
add, addChild, binarize, equals, getAncestorElements, getAncestors, getChildren, getElements, getFirstChild, getLastChild, getLeaves, getNodes, getOrderedTreeNodes, getRoot, getSiblingElements, getSiblings, getSubtrees, hasChild, hasChild, hashCode, isFirstChild, isLastChild, numSiblings, remove, removeChild, removeChild, removeChildAt, removeChildren, setChildAt, setParent, subsumes, toNewick, toNewick, toString, traverse, traverseLevelOrder, traverseNodes, traverseNodesLevelOrder, traverseNodesPostOrder, traverseNodesPreOrder, traversePostOrder, traversePreOrder
add, degree, degree, depth, depth, getElement, getLeafElements, hasAncestor, hasAncestor, hasChild, hasDescendant, hasDescendant, hasElement, hasElement, hasParent, hasParent, hasParent, isBalanced, isLabeled, isLabeledTree, isLeaf, isRoot, iterator, numLeaves, removeChildren, setElement, size, yield
addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
public BinaryTree()
public BinaryTree(E element)
element
- an element of this nodepublic BinaryTree<E> find(E element)
public BinaryTree<E> findChild(E element)
public BinaryTree<E> getParent()
public void setParent(BinaryTree<E> parent)
parent
- a parent that will be set to this nodepublic BinaryTree<E> getChildAt(int index)
getChildAt
in class OrderedTree<E>
index
- an index of the element to returnpublic BinaryTree<E> getLeftChild()
public BinaryTree<E> getDeepestLeftLeaf()
public void setLeftChild(E element)
element
- an element to be set to the left childpublic void setLeftChild(BinaryTree<E> child)
child
- a child node to be set as the left childpublic BinaryTree<E> getRightChild()
public BinaryTree<E> getDeepestRightLeaf()
public void setRightChild(E element)
element
- an element to be set to the right childpublic void setRightChild(BinaryTree<E> child)
child
- a child node to be set as the right childpublic int numChildren()
numChildren
in interface Tree<E>
numChildren
in class OrderedTree<E>
public boolean hasLeftChild()
true
if this node has a left child.true
if this node has a left child; false
otherwisepublic boolean hasLeftChild(E element)
true
if this node has a left child with the given element.element
- an element whose presence in the left child of this node will be testedtrue
if this node has a left child with the given element; false
otherwisepublic boolean hasLeftChild(BinaryTree<E> child)
true
if this node has the given left child.child
- a node whose presence in the left child of this node will be testedtrue
if this node has the given left child; false
otherwisepublic boolean hasRightChild()
true
if this node has a right child.true
if this node has a right child; false
otherwisepublic boolean hasRightChild(E element)
true
if this node has a right child with the given element.element
- an element whose presence in the right child of this node will be testedtrue
if this node has a right child with the given element; false
otherwisepublic boolean hasRightChild(BinaryTree<E> child)
true
if this node has the given right child.child
- a node whose presence in the right child of this node will be testedtrue
if this node has the given right child; false
otherwisepublic void add(BinaryTree<E> child)
child
- a child that will be added to this nodepublic void addChild(BinaryTree<E> child)
child
- a child that will be added to this nodepublic void addChild(E element)
public java.util.List<BinaryTree<E>> getBinaryTreeNodes()
BinaryTree<E>
in this tree.BinaryTree<E>
in this treepublic void removeLeftChild()
public void removeRightChild()