Package org.aksw.commons.collections
Class MultiMaps
java.lang.Object
org.aksw.commons.collections.MultiMaps
Created by Claus Stadler
Date: Oct 9, 2010
Time: 5:42:34 PM
A set of static methods for treating a Map<K, Set> as a multimap
(or rather graphs, as keys may be mapped to an empty set of values)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> void addAllKeys(Map<K, Set<V>> map, Iterable<K> keys) static <K,V> Set<V> static <K,V> boolean containsEntry(Map<K, Set<V>> map, K key, V value) static <T> Set<T>getCommonParent(Map<T, ? extends Collection<T>> map, T a, T b) Find the nearest set of nodes that are parents of both given nodes.static <K,V> void static <K,V> void static <K,V> void putAll(Map<K, Set<V>> map, K key, Collection<? extends V> vs) Creates a new map that is the reverse of the sourcestatic <K,V> Set<V> safeGet(Map<K, ? extends Collection<V>> map, Object key) This method returns an empty set (Collections.emptySet) for keys that are not in the map.static <K,V> Set<V> safeGetAll(Map<K, ? extends Collection<V>> map, Collection<?> keys) Returns the set of successors for a given set of keysstatic <K,V> Collection<V> safeGetC(Map<K, ? extends Collection<V>> map, Object key) TODO Add to collection utilstransitiveClosure(Map<T, Set<T>> map) transitiveClosure(Map<T, Set<T>> map, boolean inPlace) transitiveClosureInPlace(Map<T, Set<T>> map) static <T> Set<T>transitiveGet(Map<T, ? extends Collection<T>> map, Object key) static <T> Set<T>transitiveGetAll(Map<T, ? extends Collection<T>> map, Iterable<?> keys) static <K,V> Collection<V>
-
Constructor Details
-
MultiMaps
public MultiMaps()
-
-
Method Details
-
putAll
-
putAll
-
put
-
containsEntry
-
values
-
addKey
-
addAllKeys
-
copy
-
reverse
Creates a new map that is the reverse of the source- Type Parameters:
K-V-- Parameters:
source-- Returns:
-
safeGet
This method returns an empty set (Collections.emptySet) for keys that are not in the map.- Type Parameters:
K-V-- Parameters:
map-key-- Returns:
-
safeGetAll
Returns the set of successors for a given set of keys- Type Parameters:
K-V-- Parameters:
map-keys-- Returns:
-
safeGetC
TODO Add to collection utils- Type Parameters:
K-V-- Parameters:
map-key-- Returns:
-
transitiveGetAll
-
transitiveGet
-
transitiveClosure
-
transitiveClosure
-
transitiveClosureInPlace
-
getCommonParent
Find the nearest set of nodes that are parents of both given nodes.- Parameters:
map- A mapping from children to parentsa-b-
-