Browse Source

contains-Methode implementiert

vollständige_und_weitere_testate
hertero 3 years ago
committed by chris
parent
commit
768e5f67ba
  1. 11
      SimpleLinkedList/src/solution/SimpleLinkedList.java

11
SimpleLinkedList/src/solution/SimpleLinkedList.java

@ -62,18 +62,17 @@ public class SimpleLinkedList<E> extends AbstractSimpleList<E> {
@Override @Override
public boolean contains(Object o) { public boolean contains(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)) {
return true; return true;
} }
return false; return false;
} }
@Override @Override

Loading…
Cancel
Save