Browse Source

remove-Methode implementiert

vollständige_und_weitere_testate
hertero 3 years ago
committed by chris
parent
commit
5048b93887
  1. 16
      SimpleLinkedList/src/solution/SimpleLinkedList.java

16
SimpleLinkedList/src/solution/SimpleLinkedList.java

@ -43,19 +43,19 @@ public class SimpleLinkedList<E> extends AbstractSimpleList<E> {
@Override @Override
public boolean remove(Object o) { public boolean remove(Object o) {
if(o == null) { if (o == null) {
return false; return false;
} }
Node<E> aktuellerKnoten = ersteKnoten; Node<E> currentNode = firstNode;
while(aktuellerKnoten != null) { while (currentNode != null) {
aktuellerKnoten = aktuellerKnoten.getSuccessor(); currentNode = currentNode.getSuccessor();
} }
if(o.equals(aktuellerKnoten)) { if (o.equals(currentNode)) {
aktuellerKnoten.setPayload(null); currentNode.setPayload(null);
size--; size--;
aktuellerKnoten = aktuellerKnoten.getPredecessor(); currentNode = currentNode.getPredecessor();
return true; return true;
} }
return false; return false;
} }

Loading…
Cancel
Save