diff --git a/src/edu/kit/informatik/model/TrainManager.java b/src/edu/kit/informatik/model/TrainManager.java index 6ef1fec..82441a5 100644 --- a/src/edu/kit/informatik/model/TrainManager.java +++ b/src/edu/kit/informatik/model/TrainManager.java @@ -249,12 +249,8 @@ public final class TrainManager { */ private List> getCollisionsOfOneReverseStep() { List> collisions = new ArrayList<>(); - Map> occupiedRails = new HashMap<>(); - for (Train train : trains.values()) { - if (train.isPlaced()) { - occupiedRails.put(train, train.getOccupiedRails()); - } - } + Map> occupiedRails = trains.values().stream().filter(Train::isPlaced) + .collect(Collectors.toMap(Function.identity(), Train::getOccupiedRails)); // perform step Map> nextOccupiedRails = new HashMap<>(); trains.values().stream().filter(Train::isPlaced).forEach(train -> {