Omar_Natour

Natour, O. MostRecentlyUsedLL

Dec 2nd, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. *Omar Natour 11/30/16
  2.  * Csc-220 Data Structures
  3.  * Hw8 Spell checker
  4.  * create a program that can check words against a created dictionary class
  5.  * ojnatour0001@student.stcc.edu
  6.  */
  7.  
  8. package chapter24;
  9.  
  10. import chapter24.MyLinkedList.Node;
  11.  
  12. public class MostRecentlyUsedLinkedList<E extends String> extends MyLinkedList<E> {
  13.  
  14.     public boolean contains(E e) {
  15.  
  16.         Node<E> current = this.head;
  17.  
  18.         while (current != null) {
  19.             if (e.equalsIgnoreCase(current.element)) {
  20.                 this.remove(current.element);
  21.                 this.addFirst(current.element);
  22.  
  23.                 return true;
  24.             }
  25.             current = current.next;
  26.         }
  27.         return false;
  28.  
  29.     }
  30.  
  31. }
Add Comment
Please, Sign In to add comment