org.aksw.commons.collections
Class MultiMaps
java.lang.Object
org.aksw.commons.collections.MultiMaps
public class MultiMaps
- extends Object
Created by Claus Stadler
Date: Oct 9, 2010
Time: 5:42:34 PM
A set of static methods for treating a Map> as a multimap
(or rather graphs, as keys may be mapped to an empty set of values)
|
Method Summary |
static
|
addAllKeys(Map<K,Set<V>> map,
Iterable<K> keys)
|
static
|
addKey(Map<K,Set<V>> map,
K key)
|
static
|
containsEntry(Map<K,Set<V>> map,
K key,
V value)
|
static
|
copy(Map<K,Set<V>> source)
|
static
|
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
|
put(Map<K,Set<V>> map,
K key,
V value)
|
static
|
putAll(Map<K,Set<V>> map,
K key,
Collection<? extends V> vs)
|
static
|
putAll(Map<K,Set<V>> target,
Map<? extends K,? extends Set<? extends V>> source)
|
static
|
reverse(Map<K,Set<V>> source)
Creates a new map that is the reverse of the source |
static
|
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
|
safeGetAll(Map<K,? extends Collection<V>> map,
Collection<?> keys)
Returns the set of successors for a given set of keys |
static
|
safeGetC(Map<K,? extends Collection<V>> map,
Object key)
TODO Add to collection utils |
static
|
transitiveClosure(Map<T,Set<T>> map)
|
static
|
transitiveClosure(Map<T,Set<T>> map,
boolean inPlace)
|
static
|
transitiveClosureInPlace(Map<T,Set<T>> map)
|
static
|
transitiveGet(Map<T,? extends Collection<T>> map,
Object key)
|
static
|
values(Map<K,Set<V>> map)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MultiMaps
public MultiMaps()
putAll
public static <K,V> void putAll(Map<K,Set<V>> target,
Map<? extends K,? extends Set<? extends V>> source)
putAll
public static <K,V> void putAll(Map<K,Set<V>> map,
K key,
Collection<? extends V> vs)
put
public static <K,V> void put(Map<K,Set<V>> map,
K key,
V value)
containsEntry
public static <K,V> boolean containsEntry(Map<K,Set<V>> map,
K key,
V value)
values
public static <K,V> Collection<V> values(Map<K,Set<V>> map)
addKey
public static <K,V> Set<V> addKey(Map<K,Set<V>> map,
K key)
addAllKeys
public static <K,V> void addAllKeys(Map<K,Set<V>> map,
Iterable<K> keys)
copy
public static <K,V> Map<K,Set<V>> copy(Map<K,Set<V>> source)
reverse
public static <K,V> Map<V,Set<K>> reverse(Map<K,Set<V>> source)
- Creates a new map that is the reverse of the source
- Type Parameters:
K - V - - Parameters:
source -
- Returns:
safeGet
public static <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.
- Type Parameters:
K - V - - Parameters:
map - key -
- Returns:
safeGetAll
public static <K,V> Set<V> safeGetAll(Map<K,? extends Collection<V>> map,
Collection<?> keys)
- Returns the set of successors for a given set of keys
- Type Parameters:
K - V - - Parameters:
map - keys -
- Returns:
safeGetC
public static <K,V> Collection<V> safeGetC(Map<K,? extends Collection<V>> map,
Object key)
- TODO Add to collection utils
- Type Parameters:
K - V - - Parameters:
map - key -
- Returns:
transitiveGet
public static <T> Set<T> transitiveGet(Map<T,? extends Collection<T>> map,
Object key)
transitiveClosure
public static <T> Map<T,Set<T>> transitiveClosure(Map<T,Set<T>> map)
transitiveClosure
public static <T> Map<T,Set<T>> transitiveClosure(Map<T,Set<T>> map,
boolean inPlace)
transitiveClosureInPlace
public static <T> Map<T,Set<T>> transitiveClosureInPlace(Map<T,Set<T>> map)
getCommonParent
public 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.
- Parameters:
map - A mapping from children to parentsa - b -
Copyright © 2012. All Rights Reserved.