diff --git a/Projekte/battleship/model/src/main/java/pp/battleship/model/ShipMap.java b/Projekte/battleship/model/src/main/java/pp/battleship/model/ShipMap.java index dfab415..3bd5c20 100644 --- a/Projekte/battleship/model/src/main/java/pp/battleship/model/ShipMap.java +++ b/Projekte/battleship/model/src/main/java/pp/battleship/model/ShipMap.java @@ -105,9 +105,8 @@ public class ShipMap { * Removes all items from the map and triggers corresponding removal events for each. */ public void clear() { - for (Item item : items) { - items.remove(item); - notifyListeners(new ItemRemovedEvent(item, this)); + while (!items.isEmpty()) { + notifyListeners(new ItemRemovedEvent(items.removeFirst(), this)); } }