joey
By: a guest | Feb 9th, 2010 | Syntax:
Java | Size: 0.84 KB | Hits: 28 | Expires: Never
public void remove(DataElement datum)
{
Node tempElement = null;
Node prevElement = null;
while (i.hasNext())
{
tempElement.data = i.getNext();
if (tempElement.data.equals(datum))
{ // found it, remove
if (prevElement != null)
{
prevElement.link = tempElement.link;
}
else
{ // this was first element
first = null;
}
if (tempElement == last)
{
last = null;
}
return;
}
else
{
prevElement = tempElement;
}
}
}