From 9a467af26f0fc1918f347ccbdf581f19b2d2ca6b Mon Sep 17 00:00:00 2001 From: hertero <robert.hertel@hs-weingarten.de> Date: Tue, 30 Aug 2022 10:22:05 +0200 Subject: [PATCH] forAll-Methode implementiert --- SimpleLinkedList/src/solution/SimpleLinkedList.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/SimpleLinkedList/src/solution/SimpleLinkedList.java b/SimpleLinkedList/src/solution/SimpleLinkedList.java index 7e1f069..7e893a2 100644 --- a/SimpleLinkedList/src/solution/SimpleLinkedList.java +++ b/SimpleLinkedList/src/solution/SimpleLinkedList.java @@ -77,13 +77,12 @@ public class SimpleLinkedList<E> extends AbstractSimpleList<E> { @Override public void forAll(ICommand<E> command) { - if(command != null) { - Node<E> aktuellerKnoten = ersteKnoten; - while(aktuellerKnoten != null) { - command.execute(aktuellerKnoten.getPayload()); - aktuellerKnoten = aktuellerKnoten.getSuccessor(); + if (command != null) { + Node<E> currentNode = firstNode; + while (currentNode != null) { + command.execute(currentNode.getPayload()); + currentNode = currentNode.getSuccessor(); } - } + } } - }