edu.kit.ifv.mobitopp.simulation.publictransport.model.VehiclesAtStops Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mobitopp Show documentation
Show all versions of mobitopp Show documentation
mobiTopp (http://mobitopp.ifv.kit.edu/) is an agent-based travel demand model developed at the Institute for transport studies at the Karlsruhe Institute of Technology (http://www.ifv.kit.edu/english/index.php). Publications about mobiTopp can be found on the project site (http://mobitopp.ifv.kit.edu/28.php).
The newest version!
package edu.kit.ifv.mobitopp.simulation.publictransport.model;
import static java.util.Collections.emptySet;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import edu.kit.ifv.mobitopp.publictransport.model.Stop;
public class VehiclesAtStops {
private final Map> vehicles;
public VehiclesAtStops() {
super();
vehicles = new HashMap<>();
}
public void add(Vehicle vehicle, Stop atStop) {
if (!vehicles.containsKey(atStop)) {
vehicles.put(atStop, new LinkedHashSet<>());
}
vehicles.get(atStop).add(vehicle);
}
public boolean contains(Vehicle vehicle, Stop atStop) {
return vehicles.getOrDefault(atStop, emptySet()).contains(vehicle);
}
public void remove(Vehicle vehicle, Stop atStop) {
if(vehicles.containsKey(atStop)) {
vehicles.get(atStop).remove(vehicle);
}
}
}