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

fr.vergne.collection.impl.HashMultiMap Maven / Gradle / Ivy

There is a newer version: 1.11
Show newest version
package fr.vergne.collection.impl;

import java.util.Collection;
import java.util.HashSet;

import fr.vergne.collection.MultiMap;

/**
 * A {@link HashMultiMap} is a {@link MultiMap} which allows at most one
 * instance for each (key, value). If the same value is assigned several times
 * to the same key, it is the same than providing it only once, and removing it
 * once is enough to not have it anymore in the map.
 * 
 * @author Matthieu Vergne 
 * 
 * @param 
 * @param 
 */
@SuppressWarnings("serial")
public class HashMultiMap extends AbstractMultiMap
		implements MultiMap {

	public HashMultiMap(MultiMap map) {
		for (Entry> entry : map.entrySet()) {
			populate(entry.getKey(), entry.getValue());
		}
	}

	public HashMultiMap() {
	}

	@Override
	protected Collection generateInnerCollection(Key key) {
		return new HashSet();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy