36 lines
1.0 KiB
Java
36 lines
1.0 KiB
Java
package linkedlist;
|
|
|
|
public class Lista<E> {
|
|
|
|
Nodo<E> testa;
|
|
int size;
|
|
|
|
public Lista() {
|
|
this.testa = null;
|
|
}
|
|
|
|
public int getSize() {
|
|
return this.size;
|
|
}
|
|
|
|
public void addFirst(E info) {
|
|
if (this.testa == null) {
|
|
this.testa = new Nodo<>(info);
|
|
}
|
|
else {
|
|
Nodo<E> nuovaTesta = new Nodo<>(info);
|
|
nuovaTesta.setNext(this.testa);
|
|
this.testa = nuovaTesta;
|
|
}
|
|
}
|
|
|
|
//addFirst(tipoInfo info): aggiunge un nodo in testa (es. tipoInfo = char, tipoInfo = int)
|
|
//addLast(tipoInfo info): aggiunge un nodo in coda (es. tipoInfo = char, tipoInfo = int)
|
|
//addElementAt(tipoInfo info, int pos): aggiunge un nodo nella posizione indicata da pos
|
|
//removeFirst(): rimuove il nodo in testa
|
|
//removeLast(): rimuove il nodo in coda
|
|
//removeElementAt(int pos): rimuove il nodo in coda
|
|
//tipoInfo getElementAt(int pos): restituisce l'info presente nel nodo in posizione n (es. tipoInfo = char, tipoInfo = int)
|
|
//String toString()
|
|
}
|