Guest User

Untitled

a guest
Dec 16th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. //If not, go through a for loop (count) amount of times or until found==true
  2. else
  3. {
  4. current = contents.getNext();
  5. //Looks like it just goes through the linkedset while saving the previous element so it can do previous.setNext at the end
  6. for (int look=0; look < count && !found; look++)
  7. if (current.getElement().equals(target))
  8. found = true;
  9. else
  10. {
  11. current = current.getNext();
  12. }
  13.  
  14. if (!found)
  15. throw new NoSuchElementException();
  16. //So to get here, current equals the element, and you need to setnext the previous to current.getNext
  17. result = current.getElement();
  18. current.getPrevious().setNext(current.getNext());
  19. }
Add Comment
Please, Sign In to add comment