From eccc317beafa4e42ca225c391ffeb7235b97f2a4 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sun, 9 Nov 2014 11:33:50 +0100 Subject: [PATCH] Remove the need for an Iterator within the lists remove method. --- .../datastructure/ConcurrentLinkedList.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/de/teamteamteam/spacescooter/datastructure/ConcurrentLinkedList.java b/src/de/teamteamteam/spacescooter/datastructure/ConcurrentLinkedList.java index 760b65d..9a8b721 100644 --- a/src/de/teamteamteam/spacescooter/datastructure/ConcurrentLinkedList.java +++ b/src/de/teamteamteam/spacescooter/datastructure/ConcurrentLinkedList.java @@ -43,13 +43,13 @@ public class ConcurrentLinkedList { * Remove an element from the list. */ public void remove(T element) { - ConcurrentIterator iter = this.iterator(); - while (iter.hasNext()) { - T e = iter.next(); - if (e.equals(element)) { - iter.remove(); - return; - } + ConcurrentLinkedListNode currentNode = this.head; + while(element.equals(currentNode.getValue()) == false && currentNode.hasNext()) { + currentNode = currentNode.next(); + } + if(currentNode.getValue().equals(element)) { + currentNode.setValue(null); + return; } }