Public paste
Undefined
By: CSC | Date: Oct 22 2009 19:16 | Format: None | Expires: never | Size: 948 B | Hits: 848

  1. public boolean remove(int input)
  2.                 {
  3.                         Node temp = head;
  4.                         if(isEmpty()){return(false);}
  5.                         if(contains(input))
  6.                         {
  7.                                 do{
  8.                                         if(temp.data == input)
  9.                                         {
  10.                                                 if(head.data == input)
  11.                                                 {
  12.                                                         head = head.next;
  13.                                                         nextNode = head;
  14.                                                         count--;
  15.                                                         return(true);
  16.                                                 }
  17.                                                 if(temp.next == null && head == temp)
  18.                                                 {
  19.                                                         head = null;
  20.                                                         tail = null;
  21.                                                         count--;
  22.                                                         System.out.println("here");
  23.                                                         return(true);
  24.                                                 }
  25.                                        
  26.                                                 else if(temp.next == null && tail == temp)
  27.                                                 {
  28.                                                         tail = back;
  29.                                                         back.next = null;
  30.                                                         System.out.println("front");
  31.                                                         count--;       
  32.                                                         return(true);                                  
  33.                                                 }
  34.                                                 else
  35.                                                 {
  36.                                                         back.next = temp.next;
  37.                                                         temp = null;
  38.                                                         count--;
  39.                                                         return(true);
  40.                                                 }
  41.                                         }      
  42.                                         else
  43.                                         {
  44.                                                 back = temp;
  45.                                                 temp = temp.next;
  46.                                         }
  47.                         }while(temp != null);
  48.                 }
  49.                         return(false);
  50.                 }