public class Maps
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <K,V1,V2> void |
addAll(java.util.Map<K,V1> to,
java.util.Map<K,V2> from,
java.util.function.Function<V2,V1> function)
Adds all of the keys in
from to to ,
applying function to the values to transform them
from V2 to V1 . |
static <X,Y,Z> java.util.Map<X,Z> |
compose(java.util.Map<X,Y> map1,
java.util.Map<Y,Z> map2)
Compose two maps map1:x->y and map2:y->z to get a map x->z
|
static <T,V> java.util.Map<T,V> |
getAll(java.util.Map<T,V> map,
java.util.Collection<T> indices)
get all values corresponding to the indices (if they exist in the map)
|
static boolean |
getBool(java.util.Map<java.lang.String,java.lang.String> props,
java.lang.String key)
Load a boolean property from a Map.
|
static boolean |
getBool(java.util.Map<java.lang.String,java.lang.String> props,
java.lang.String key,
boolean defaultValue)
Load a boolean property from a Map.
|
static <X,Y> java.util.Map<Y,X> |
invert(java.util.Map<X,Y> map)
Inverts a map x->y to a map y->x assuming unique preimages.
|
static <X,Y> java.util.Map<Y,java.util.Set<X>> |
invertSet(java.util.Map<X,Y> map)
Inverts a map x->y to a map y->pow(x) not assuming unique preimages.
|
static void |
main(java.lang.String[] args) |
static <K,V> void |
putIntoValueArrayList(java.util.Map<K,java.util.List<V>> map,
K key,
V value)
Adds the value to the ArrayList given by map.get(key), creating a new ArrayList if needed.
|
static <K,V,C extends java.util.Collection<V>> |
putIntoValueCollection(java.util.Map<K,C> map,
K key,
V value,
CollectionFactory<V> cf)
Adds the value to the collection given by map.get(key).
|
static <K,V> void |
putIntoValueHashSet(java.util.Map<K,java.util.Set<V>> map,
K key,
V value)
Adds the value to the HashSet given by map.get(key), creating a new HashMap if needed.
|
static <K,V> void |
removeKeys(java.util.Map<K,V> map,
java.util.Collection<K> removekeys)
Removes keys from the map
|
static <K extends java.lang.Comparable<? super K>,V> |
sortedEntries(java.util.Collection<java.util.Map.Entry<K,V>> entries)
Sorts a list of entries.
|
static <K extends java.lang.Comparable<? super K>,V> |
sortedEntries(java.util.Map<K,V> map)
Returns a List of entries in the map, sorted by key.
|
static <T,V> java.lang.String |
toString(java.util.Map<T,V> map,
java.lang.String preAppend,
java.lang.String postAppend,
java.lang.String keyValSeparator,
java.lang.String itemSeparator)
Pretty print a Counter.
|
static <K extends java.lang.Comparable<K>,V> |
toStringSorted(java.util.Map<K,V> map)
Stringifies a Map in a stable fashion.
|
static <K extends java.lang.Comparable<K>,V> |
toStringSorted(java.util.Map<K,V> map,
java.lang.StringBuilder builder)
Stringifies a Map in a stable fashion.
|
public static <K,V> void putIntoValueHashSet(java.util.Map<K,java.util.Set<V>> map, K key, V value)
public static <K,V> void putIntoValueArrayList(java.util.Map<K,java.util.List<V>> map, K key, V value)
public static <K,V,C extends java.util.Collection<V>> void putIntoValueCollection(java.util.Map<K,C> map, K key, V value, CollectionFactory<V> cf)
public static <X,Y,Z> java.util.Map<X,Z> compose(java.util.Map<X,Y> map1, java.util.Map<Y,Z> map2)
public static <X,Y> java.util.Map<Y,X> invert(java.util.Map<X,Y> map)
public static <X,Y> java.util.Map<Y,java.util.Set<X>> invertSet(java.util.Map<X,Y> map)
public static <K extends java.lang.Comparable<? super K>,V> java.util.List<java.util.Map.Entry<K,V>> sortedEntries(java.util.Collection<java.util.Map.Entry<K,V>> entries)
public static <K extends java.lang.Comparable<? super K>,V> java.util.List<java.util.Map.Entry<K,V>> sortedEntries(java.util.Map<K,V> map)
public static <K extends java.lang.Comparable<K>,V> void toStringSorted(java.util.Map<K,V> map, java.lang.StringBuilder builder)
public static <K extends java.lang.Comparable<K>,V> java.lang.String toStringSorted(java.util.Map<K,V> map)
public static <K,V> void removeKeys(java.util.Map<K,V> map, java.util.Collection<K> removekeys)
public static <K,V1,V2> void addAll(java.util.Map<K,V1> to, java.util.Map<K,V2> from, java.util.function.Function<V2,V1> function)
from
to to
,
applying function
to the values to transform them
from V2
to V1
.public static <T,V> java.util.Map<T,V> getAll(java.util.Map<T,V> map, java.util.Collection<T> indices)
map
- indices
- public static boolean getBool(java.util.Map<java.lang.String,java.lang.String> props, java.lang.String key)
public static boolean getBool(java.util.Map<java.lang.String,java.lang.String> props, java.lang.String key, boolean defaultValue)
public static <T,V> java.lang.String toString(java.util.Map<T,V> map, java.lang.String preAppend, java.lang.String postAppend, java.lang.String keyValSeparator, java.lang.String itemSeparator)
public static void main(java.lang.String[] args)