import java.util.Vector;
/**
- * Dynamic representation of all Rics in the system.
+ * A map, where each key can be bound to may values (where each value has an own
+ * ID)
*/
-
public class MultiMap<T> {
private final Map<String, Map<String, T>> map = new HashMap<>();
this.map.computeIfAbsent(key, k -> new HashMap<>()).put(id, value);
}
- public void remove(String key, String id) {
+ public T remove(String key, String id) {
Map<String, T> innerMap = this.map.get(key);
if (innerMap != null) {
- innerMap.remove(id);
+ T removedElement = innerMap.remove(id);
if (innerMap.isEmpty()) {
this.map.remove(key);
}
+ return removedElement;
}
+ return null;
}
public Collection<T> get(String key) {