K - key type
V - value type
public class KataMap<K,V>
Persistent/Immutable implementation of a HashMap. This is a port of https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentHashMap.java Create
val empty = KataMap()
val map = KataMap("a" to 1, "b" to 2)
Put
KataMap() + ("a" to 1")
KataMap().put("a", 1)
Del
val map = KataMap("a" to 1, "b" to 2)
val onlyB = map - "a"
val empty = map.del("a") - "b"
Get
val map = KataMap("a" to 1, "b" to 2)
val aValue = map["a"]
val none = map["c"] // null
val (a,b,c) = map["a", "b", "c"] // destructuring up to arity 8 (inclusive)
Size
val map = KataMap("a" to 1, "b" to 2)
map.size
map.isEmpty()
map.isNotEmpty()
Query
val map = KataMap("a" to 1, "b" to 2)
map.containsKey("a")
map.containsValue(2)
"a" in map
"c" !in map
Iteration
val map = KataMap("a" to 1, "b" to 2)
for ((k, v) in map) {
//...
}
map.iterator()
map.asSequence() // Sequence>
map.entries // Set>
map.keys // Set
map.values // Collection
@NotNull public KataMap<K,V> put(K k, V v)
k - keyv - valueclass KataMap containing all the key-value pairs of this KataMap and key-value pair k, v
Note that k,v will overwrite corresponding key-value pairs in this KataMap@NotNull public KataMap<K,V> put(@NotNull kotlin.Pair<? extends K,? extends V> kv, @NotNull kotlin.Pair... kvs)
kv - key-value pair to addkvs - key-value pairs to addclass KataMap containing all key-value pairs of this KataMap and key-value pairs kv and kvs@NotNull public KataMap<K,V> put(@NotNull java.util.Map.Entry<? extends K,? extends V> kv, @NotNull java.util.Map.Entry... kvs)
kv - key-value pair to addkvs - key-value pairs to addclass KataMap containing all key-value pairs of this KataMap and key-value pairs kv and kvs@NotNull public KataMap<K,V> plus(@NotNull kotlin.Pair<? extends K,? extends V> kv)
kv - key-value pair to addclass KataMap containing all key-value pairs of this KataMap and kv
Note that kv will overwrite corresponding key-value pairs in this KataMap@NotNull public KataMap<K,V> plus(@NotNull java.util.Map.Entry<? extends K,? extends V> kv)
kv - key-value pair to addclass KataMap containing all key-value pairs of this KataMap and kv
Note that kv will overwrite corresponding key-value pairs in this KataMap@NotNull public KataMap<K,V> plus(@NotNull java.util.Map<K,? extends V> other)
other - map to merge with this KataMapclass KataMap containing all the key-value pairs of this KataMap and all key-values pairs of other.
Note that key-value pairs in other will overwrite corresponding key-value pairs in this KataMap@NotNull public KataMap<K,V> merge(@NotNull java.util.Map<K,? extends V> other)
other - map to merge with this KataMapclass KataMap containing all the key-value pairs of this KataMap and all key-values pairs of other.
Note that key-value pairs in other will overwrite corresponding key-value pairs in this KataMap@NotNull public KataMap<K,V> plus(@NotNull java.util.Collection<? extends kotlin.Pair<? extends K,? extends V>> kvs)
kvs - Collection of key-value pairs to merge with this Katamapclass KataMap containing all the key-value pairs of this KataMap and all key-values pairs of kvs.
Note that key-value pairs in kvs will overwrite corresponding key-value pairs in this KataMap@NotNull public KataMap<K,V> del(K k)
k - key to removeclass KataMap containing all key-value pairs except for k@NotNull public KataMap<K,V> del(K k, @NotNull K... ks)
k - key to removeks - keys to removeclass KataMap containing all key-value pairs except for k and ks@NotNull public KataMap<K,V> minus(K k)
k - key to removeclass KataMap containing all key-value pairs except for k@NotNull public KataMap<K,V> minus(@NotNull java.util.Collection<? extends K> keys)
keys - keys to removeclass KataMap containing all key-value pairs except for keys@Nullable public V get(java.lang.Object k)
@NotNull
public kotlin.Pair<V,V> get(K k0,
K k1)
@NotNull
public kotlin.Triple<V,V,V> get(K k0,
K k1,
K k2)
@NotNull public KTuple4<V,V,V,V> get(K k0, K k1, K k2, K k3)
@NotNull public KTuple5<V,V,V,V,V> get(K k0, K k1, K k2, K k3, K k4)
@NotNull public KTuple6<V,V,V,V,V,V> get(K k0, K k1, K k2, K k3, K k4, K k5)
@NotNull public KTuple7<V,V,V,V,V,V,V> get(K k0, K k1, K k2, K k3, K k4, K k5, K k6)
@NotNull public KTuple8<V,V,V,V,V,V,V,V> get(K k0, K k1, K k2, K k3, K k4, K k5, K k6, K k7)
public boolean contains(K key)
key - key to lookupkey, false otherwisepublic boolean containsKey(java.lang.Object key)
key - key to lookupkey, false otherwisepublic boolean containsValue(java.lang.Object value)
value - value to lookupvalue, false otherwise@NotNull public java.util.Set<java.util.Map.Entry> getEntries()
A Set (backed by this KataMap) containing all key-value pairs in this KataMap
@NotNull public java.util.Set<K> getKeys()
A Set (backed by this KataMap) containing all keys in this KataMap
@NotNull public java.util.Collection<V> getValues()
A Collection containing all values in this KataMap
public boolean equals(@Nullable
java.lang.Object other)
public int hashCode()
@NotNull public java.lang.String toString()
public int getSize()