All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.kit.ifv.mobitopp.simulation.publictransport.model.VehiclesAtStops Maven / Gradle / Ivy

Go to download

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);
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy