Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Name:Nate Wheeler
- * Date:november 18, 2016
- * Course Number: csc220
- * Course Name: data structures
- * Problem Number: hw08
- * Email: nate23nate23@gmail.com
- * Short Description of the Problem
- * make spell-checker using a dictionary
- */
- package compsci220;
- public class MostRecentlyUsedLinkedList<E extends String> extends MyLinkedList<String>{
- public boolean contains(E e){
- if(head == null)
- return false;
- Node<E> current=(compsci220.MyLinkedList.Node<E>) head;
- while(current.next != null){
- //comparing both elements
- if(current.element.equals(e)){
- //removes the element of current by its index and places it in front of the list
- addFirst(remove(indexOf((String) current.element)));
- return true;
- }
- else {
- current=current.next;
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement