ho dei dubbi su questa parte di esercizio.
Java:
public class MyIntegerList
{
//Variabili Statiche
//Campi
MyIntegerListElement head;
MyIntegerListElement tail;
//Costruttori
public MyIntegerList()
{
this.head=null;
}
//Metodi
public void add(int value)
{
MyIntegerListElement temp = new MyIntegerListElement(value);
MyIntegerListElement coda = null;
if(this.head!=null)
{
for(coda=this.head; coda.getNext()!=null; coda=coda.getNext());
coda.setNext(temp);
}
else
{
this.head=temp;
}
}
public void addFirst(int value)
{
this.head = new MyIntegerListElement(value, this.head);
}
public int get(int pos)
{
MyIntegerListElement coda = null;
int i;
for(i=0, coda=this.head;i<pos && coda!=null; i++, coda=coda.getNext());
if(coda!=null)
return coda.getValue();
return -1;
}
//------------------------------------------------------------------------------------------------------------------------------
public boolean contains(final int[] array, final int value)
{
for (final int i : array)
{
if (i == value)
{
return true;
}
}
return false;
}
public void delete(int element)
{
if (head == tail)
{
head = null;
tail = null;
}
else
{
head = head.next;
}
}
public int size()
{
node n = head;
node m = tail;
if(n == null)
{
return 0;
}
int size = 1;
While(n!=m);
{
size++;
n=n.getNext();
}
return size;
}
}