joey
By: a guest | Feb 9th, 2010 | Syntax:
Java | Size: 0.89 KB | Hits: 11 | Expires: Never
public void remove(DataElement datum)
{
boolean found = false;
Node tempElement = null;
Node prevElement = null;
while (i.hasNext() || !found)
{
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;
}
found = true;
}
else
{
prevElement = tempElement;
}
}
}