Interface PMap<K,V>
- Type Parameters:
K- the type of keys maintained by this mapV- the type of mapped values
public interface PMap<K,V>
Persistent (functional) Map.
- Author:
- Evgeny Mandrikov
-
Method Summary
Modifier and TypeMethodDescriptionentries()voidforEach(BiConsumer<K, V> action) Performs the given action for each entry in this map until all entries have been processed or the action throws an exception.booleanisEmpty()keySet()static <K,V> PMap<K, V> of()Returns a persistent map containing zero mappings.static <K,V> PMap<K, V> of(K k1, V v1) Returns a persistent map containing a single mapping.static <K,V> PMap<K, V> of(K k1, V v1, K k2, V v2) Returns a persistent map containing two mappings.static <K,V> PMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3) Returns a persistent map containing three mappings.static <K,V> PMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4) Returns a persistent map containing four mappings.static <K,V> PMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) Returns a persistent map containing five mappings.static <K,V> PMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6) Returns a persistent map containing six mappings.static <K,V> PMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) Returns a persistent map containing seven mappings.static <K,V> PMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8) Returns a persistent map containing eight mappings.static <K,V> PMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9) Returns a persistent map containing nine mappings.static <K,V> PMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10) Returns a persistent map containing ten mappings.toString()The string representation consists of a list of key-value mappings in the ascending order of hash codes of keys.
-
Method Details
-
put
- Returns:
- new map with added key-value pair, or this if map already contains given key-value pair
-
remove
- Returns:
- new map with removed key, or this if map does not contain given key
-
get
- Returns:
- value associated with given key, or null if not found
-
forEach
Performs the given action for each entry in this map until all entries have been processed or the action throws an exception. -
isEmpty
boolean isEmpty()- Returns:
- true if this map contains no elements
-
toString
String toString()The string representation consists of a list of key-value mappings in the ascending order of hash codes of keys. If two keys have same hash code, then their relative order is arbitrary, but stable. -
entries
-
keySet
- Returns:
- a set view of the keys contained in the map.
-
of
Returns a persistent map containing zero mappings.- Type Parameters:
K- thePMap's key typeV- thePMap's value type- Returns:
- an empty
PMap
-
of
Returns a persistent map containing a single mapping.- Type Parameters:
K- thePMap's key typeV- thePMap's value type- Parameters:
k1- the mapping's keyv1- the mapping's value- Returns:
- a
PMapcontaining the specified mapping
-
of
Returns a persistent map containing two mappings.- Type Parameters:
K- thePMap's key typeV- thePMap's value type- Parameters:
k1- the first mapping's keyv1- the first mapping's valuek2- the second mapping's keyv2- the second mapping's value- Returns:
- a
PMapcontaining the specified mappings
-
of
Returns a persistent map containing three mappings.- Type Parameters:
K- thePMap's key typeV- thePMap's value type- Parameters:
k1- the first mapping's keyv1- the first mapping's valuek2- the second mapping's keyv2- the second mapping's valuek3- the third mapping's keyv3- the third mapping's value- Returns:
- a
PMapcontaining the specified mappings
-
of
Returns a persistent map containing four mappings.- Type Parameters:
K- thePMap's key typeV- thePMap's value type- Parameters:
k1- the first mapping's keyv1- the first mapping's valuek2- the second mapping's keyv2- the second mapping's valuek3- the third mapping's keyv3- the third mapping's valuek4- the fourth mapping's keyv4- the fourth mapping's value- Returns:
- a
PMapcontaining the specified mappings
-
of
Returns a persistent map containing five mappings.- Type Parameters:
K- thePMap's key typeV- thePMap's value type- Parameters:
k1- the first mapping's keyv1- the first mapping's valuek2- the second mapping's keyv2- the second mapping's valuek3- the third mapping's keyv3- the third mapping's valuek4- the fourth mapping's keyv4- the fourth mapping's valuek5- the fifth mapping's keyv5- the fifth mapping's value- Returns:
- a
PMapcontaining the specified mappings
-
of
Returns a persistent map containing six mappings.- Type Parameters:
K- thePMap's key typeV- thePMap's value type- Parameters:
k1- the first mapping's keyv1- the first mapping's valuek2- the second mapping's keyv2- the second mapping's valuek3- the third mapping's keyv3- the third mapping's valuek4- the fourth mapping's keyv4- the fourth mapping's valuek5- the fifth mapping's keyv5- the fifth mapping's valuek6- the sixth mapping's keyv6- the sixth mapping's value- Returns:
- a
PMapcontaining the specified mappings
-
of
static <K,V> PMap<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7) Returns a persistent map containing seven mappings.- Type Parameters:
K- thePMap's key typeV- thePMap's value type- Parameters:
k1- the first mapping's keyv1- the first mapping's valuek2- the second mapping's keyv2- the second mapping's valuek3- the third mapping's keyv3- the third mapping's valuek4- the fourth mapping's keyv4- the fourth mapping's valuek5- the fifth mapping's keyv5- the fifth mapping's valuek6- the sixth mapping's keyv6- the sixth mapping's valuek7- the seventh mapping's keyv7- the seventh mapping's value- Returns:
- a
PMapcontaining the specified mappings
-
of
static <K,V> PMap<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8) Returns a persistent map containing eight mappings.- Type Parameters:
K- thePMap's key typeV- thePMap's value type- Parameters:
k1- the first mapping's keyv1- the first mapping's valuek2- the second mapping's keyv2- the second mapping's valuek3- the third mapping's keyv3- the third mapping's valuek4- the fourth mapping's keyv4- the fourth mapping's valuek5- the fifth mapping's keyv5- the fifth mapping's valuek6- the sixth mapping's keyv6- the sixth mapping's valuek7- the seventh mapping's keyv7- the seventh mapping's valuek8- the eighth mapping's keyv8- the eighth mapping's value- Returns:
- a
PMapcontaining the specified mappings
-
of
static <K,V> PMap<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9) Returns a persistent map containing nine mappings.- Type Parameters:
K- thePMap's key typeV- thePMap's value type- Parameters:
k1- the first mapping's keyv1- the first mapping's valuek2- the second mapping's keyv2- the second mapping's valuek3- the third mapping's keyv3- the third mapping's valuek4- the fourth mapping's keyv4- the fourth mapping's valuek5- the fifth mapping's keyv5- the fifth mapping's valuek6- the sixth mapping's keyv6- the sixth mapping's valuek7- the seventh mapping's keyv7- the seventh mapping's valuek8- the eighth mapping's keyv8- the eighth mapping's valuek9- the ninth mapping's keyv9- the ninth mapping's value- Returns:
- a
PMapcontaining the specified mappings
-
of
static <K,V> PMap<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8, K k9, V v9, K k10, V v10) Returns a persistent map containing ten mappings.- Type Parameters:
K- thePMap's key typeV- thePMap's value type- Parameters:
k1- the first mapping's keyv1- the first mapping's valuek2- the second mapping's keyv2- the second mapping's valuek3- the third mapping's keyv3- the third mapping's valuek4- the fourth mapping's keyv4- the fourth mapping's valuek5- the fifth mapping's keyv5- the fifth mapping's valuek6- the sixth mapping's keyv6- the sixth mapping's valuek7- the seventh mapping's keyv7- the seventh mapping's valuek8- the eighth mapping's keyv8- the eighth mapping's valuek9- the ninth mapping's keyv9- the ninth mapping's valuek10- the tenth mapping's keyv10- the tenth mapping's value- Returns:
- a
PMapcontaining the specified mappings
-