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
public boolean remove(Object o) {
if(o == null) {
if (o == null) {
return false;
}
Node<E> aktuellerKnoten = ersteKnoten;
while(aktuellerKnoten != null) {
aktuellerKnoten = aktuellerKnoten.getSuccessor();
Node<E> currentNode = firstNode;
while (currentNode != null) {
currentNode = currentNode.getSuccessor();
}
if(o.equals(aktuellerKnoten)) {
aktuellerKnoten.setPayload(null);
if (o.equals(currentNode)) {
currentNode.setPayload(null);
size--;
aktuellerKnoten = aktuellerKnoten.getPredecessor();
currentNode = currentNode.getPredecessor();
return true;
}
return false;
}

Loading…
Cancel
Save