Share Pastebin
Guest
Public paste!

joey

By: a guest | Feb 9th, 2010 | Syntax: Java | Size: 0.89 KB | Hits: 11 | Expires: Never
Copy text to clipboard
  1.  public void remove(DataElement datum)
  2.     {
  3.         Iterator i = this.iterator();
  4.         boolean found = false;
  5.         Node tempElement = null;
  6.         Node prevElement = null;
  7.        
  8.         while (i.hasNext() ||  !found)
  9.         {
  10.             tempElement.data = i.getNext();
  11.             if (tempElement.data.equals(datum))
  12.             {   // found it, remove
  13.                 if (prevElement != null)
  14.                 {
  15.                     prevElement.link = tempElement.link;
  16.                 }
  17.                 else
  18.                 {   // this was first element
  19.                     first = null;
  20.                 }
  21.                 if (tempElement == last)
  22.                 {
  23.                     last = null;
  24.                 }      
  25.                 found = true;
  26.             }
  27.             else
  28.             {
  29.                 prevElement = tempElement;
  30.             }
  31.         }
  32.     }