Remove the need for an Iterator within the lists remove method.
This commit is contained in:
parent
64039fdee7
commit
eccc317bea
|
@ -43,13 +43,13 @@ public class ConcurrentLinkedList<T> {
|
||||||
* Remove an element from the list.
|
* Remove an element from the list.
|
||||||
*/
|
*/
|
||||||
public void remove(T element) {
|
public void remove(T element) {
|
||||||
ConcurrentIterator<T> iter = this.iterator();
|
ConcurrentLinkedListNode<T> currentNode = this.head;
|
||||||
while (iter.hasNext()) {
|
while(element.equals(currentNode.getValue()) == false && currentNode.hasNext()) {
|
||||||
T e = iter.next();
|
currentNode = currentNode.next();
|
||||||
if (e.equals(element)) {
|
}
|
||||||
iter.remove();
|
if(currentNode.getValue().equals(element)) {
|
||||||
return;
|
currentNode.setValue(null);
|
||||||
}
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue