public class AVLTree<E extends java.lang.Comparable<E>>
extends java.lang.Object
E
e non si possono inserire elementi null
.Modifier and Type | Class and Description |
---|---|
class |
AVLTree.AVLTreeNode
Gli elementi di questa classe sono i nodi di un AVLTree, che è la classe
"involucro" della struttura dati.
|
Constructor and Description |
---|
AVLTree()
Costruisce un AVLTree vuoto.
|
AVLTree(E rootElement)
Costruisce un AVLTree che consiste solo di un nodo radice.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(E el)
Determina se questo AVLTree contiene un certo elemento.
|
int |
getCount(E el)
Determina il numero di occorrenze di un certo elemento in questo AVLTree.
|
int |
getHeight()
Restituisce l'altezza di questo AVLTree.
|
E |
getMaximum()
Restituisce l'elemento massimo presente in questo AVLTree.
|
E |
getMinimum()
Restituisce l'elemento minimo presente in questo AVLTree.
|
AVLTree.AVLTreeNode |
getNodeOf(E el)
Determina se un elemento è presente in questo AVLTree e ne restituisce il
relativo nodo.
|
int |
getNumberOfNodes()
Restituisce il numero di nodi in questo AVLTree.
|
E |
getPredecessor(E el)
Restituisce l'elemento strettamente predecessore, in questo
AVLTree, di un dato elemento.
|
AVLTree.AVLTreeNode |
getRoot() |
int |
getSize()
Restituisce il numero di elementi contenuti in questo AVLTree.
|
E |
getSuccessor(E el)
Restituisce l'elemento strettamente successore, in questo AVLTree,
di un dato elemento.
|
java.util.List<E> |
inOrderVisit()
Restituisce la lista degli elementi contenuti in questo AVLTree secondo
l'ordine determinato dalla visita in-order.
|
int |
insert(E el)
Inserisce un nuovo elemento in questo AVLTree.
|
boolean |
isBalanced()
Determina se questo AVLTree è bilanciato.
|
boolean |
isEmpty()
Determina se questo AVLTree è vuoto.
|
void |
setRoot(AVLTree.AVLTreeNode root) |
java.lang.String |
toString() |
public AVLTree()
public AVLTree(E rootElement)
rootElement
- l'informazione associata al nodo radicejava.lang.NullPointerException
- se l'elemento passato è nullpublic boolean isEmpty()
public int getSize()
E
presenti in questo
AVLTree.public int getNumberOfNodes()
public int getHeight()
public AVLTree.AVLTreeNode getRoot()
public void setRoot(AVLTree.AVLTreeNode root)
root
- the root to setpublic boolean isBalanced()
public int insert(E el)
el
- l'elemento da inserire.E
effettuati durante l'inserimentojava.lang.NullPointerException
- se l'elemento el
è nullpublic boolean contains(E el)
el
- l'elemento da cercarejava.lang.NullPointerException
- se l'elemento el
è nullpublic AVLTree.AVLTreeNode getNodeOf(E el)
el
- l'elemento da cercareel
e la
sua molteplicità, oppure null
se l'elemento el
non è presente in questo AVLTree.java.lang.NullPointerException
- se l'elemento el
è nullpublic int getCount(E el)
el
- l'elemento di cui determinare il numero di occorrenzeel
in questo
AVLTree, zero se non è presente.java.lang.NullPointerException
- se l'elemento el
è nullpublic java.lang.String toString()
toString
in class java.lang.Object
public java.util.List<E> inOrderVisit()
E
. Nel caso di elementi
ripetuti, essi appaiono più volte nella lista consecutivamente.public E getMinimum()
null
se questo
AVLTree è vuoto.public E getMaximum()
null
se questo
AVLTree è vuoto.public E getSuccessor(E el)
el
- l'elemento di cui si chiede il successoreE
, di el
in
questo AVLTree, oppure null
se el
è l'elemento
massimo.java.lang.NullPointerException
- se l'elemento el
è nulljava.lang.IllegalArgumentException
- se l'elemento el
non è
presente in questo AVLTree.public E getPredecessor(E el)
el
- l'elemento di cui si chiede il predecessoreE
, di el
in
questo AVLTree, oppure null
se el
è l'elemento
minimo.java.lang.NullPointerException
- se l'elemento el
è nulljava.lang.IllegalArgumentException
- se l'elemento el
non è
presente in questo AVLTree.