Share Pastebin
Guest
Public paste!

joey

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