EldiraSesto

Untitled

May 13th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. public boolean remove(Object o) {
  2. ContainerElement<E> n = (ContainerElement<E>) head;
  3. ContainerElement<E> p = (ContainerElement<E>) head;
  4. do {
  5. if(n.data==o) {
  6. n.data=null;
  7. n=(ContainerElement<E>) n.next;
  8. p.next=n;
  9. return true;
  10.  
  11. }
  12. else {
  13. n=(ContainerElement<E>) n.next;
  14. p=(ContainerElement<E>) p.next;
  15. }
  16.  
  17. }while(n.hasNextElement());
  18.  
  19. if(n.data==o) {
  20. n.data=null;
  21. return true;
  22. }
  23.  
  24. return false;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment