@NotThreadSafe public final class BinarySearchTree<E> extends Object implements BinaryTree<E,BinaryTreeNode<E>>, SortingTree<E,BinaryTreeNode<E>>
BinaryTree
that is also a SortingTree
. The tree is
mutated by adding new elements to the tree and allowing the tree to place the nodes.Constructor and Description |
---|
BinarySearchTree(Comparator<E> comparator) |
Modifier and Type | Method and Description |
---|---|
BinarySearchTree<E> |
addElement(E element)
Add an element to the tree at the next position
|
Comparator<E> |
getComparator() |
BinaryTreeNode<E> |
getRoot() |
boolean |
isEmpty() |
static <E> TypeKey<BinarySearchTree<E>> |
typeKey()
Construct a TypeKey for a specific element type.
|
public BinarySearchTree(Comparator<E> comparator)
public BinarySearchTree<E> addElement(E element)
MutableOrganisedTree
addElement
in interface MutableOrganisedTree<E,BinaryTreeNode<E>>
element
- the element to addpublic BinaryTreeNode<E> getRoot()
getRoot
in interface Tree<E,BinaryTreeNode<E>>
public boolean isEmpty()
isEmpty
in interface Tree<E,BinaryTreeNode<E>>
true
if the tree is emptypublic static <E> TypeKey<BinarySearchTree<E>> typeKey()
typeKey
in interface BinaryTree<E,BinaryTreeNode<E>>
typeKey
in interface Tree<E,BinaryTreeNode<E>>
E
- The element typepublic Comparator<E> getComparator()
getComparator
in interface SortingTree<E,BinaryTreeNode<E>>
Copyright © 2014–2016. All rights reserved.