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 Mapinvalid input: '<'K, Set> as a multimap (or rather graphs, as keys may be mapped to an empty set of values)
  • Constructor Details

    • MultiMaps

      public MultiMaps()
  • Method Details

    • 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:
    • transitiveGetAll

      public static <T> Set<T> transitiveGetAll(Map<T, ? extends Collection<T>> map, Iterable<?> keys)
    • 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 parents
      a -
      b -