public final class HashMap<K,V> extends java.lang.Object implements ImmutableMap<K,V>, PersistentMap<K,V>, Higher2<DataWitness.hashMap,K,V>, java.io.Serializable
Constructor and Description |
---|
HashMap() |
Modifier and Type | Method and Description |
---|---|
<R1,R2> HashMap<R1,R2> |
bimap(java.util.function.BiFunction<? super K,? super V,? extends Tuple2<R1,R2>> map) |
<R1,R2> HashMap<R1,R2> |
bimap(java.util.function.Function<? super K,? extends R1> fn1,
java.util.function.Function<? super V,? extends R2> fn2)
Transform this BiTransformable, changing two value types at once.
|
HashMap<K,V> |
bipeek(java.util.function.Consumer<? super K> c1,
java.util.function.Consumer<? super V> c2)
Peek at two data types simulatanously (typically to perform a side-effect with each data point)
|
<K2,V2> HashMap<K2,V2> |
concatMap(java.util.function.BiFunction<? super K,? super V,? extends java.lang.Iterable<Tuple2<K2,V2>>> mapper) |
boolean |
contains(Tuple2<K,V> t) |
boolean |
containsKey(K key) |
static <K,V> HashMap<K,V> |
empty() |
boolean |
equals(java.lang.Object o) |
HashMap<K,V> |
filter(java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Keep only elements for which the supplied predicates hold
e.g.
|
HashMap<K,V> |
filterKeys(java.util.function.Predicate<? super K> predicate) |
HashMap<K,V> |
filterNot(java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Remove any elements for which the predicate holds (inverse operation to filter)
e.g.
|
HashMap<K,V> |
filterValues(java.util.function.Predicate<? super V> predicate) |
<K2,V2> HashMap<K2,V2> |
flatMap(java.util.function.BiFunction<? super K,? super V,? extends ImmutableMap<K2,V2>> mapper) |
<K1,K2,R1,R> |
forEach2(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1,
java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends Tuple2<K2,R>> yieldingFunction) |
<K1,K2,R1,R> |
forEach2(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1,
java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,java.lang.Boolean> filterFunction,
java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends Tuple2<K2,R>> yieldingFunction) |
<K1,K2,K3,R1,R2,R> |
forEach3(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1,
java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2,
Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends Tuple2<K3,R>> yieldingFunction) |
<K1,K2,K3,R1,R2,R> |
forEach3(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1,
java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2,
Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,java.lang.Boolean> filterFunction,
Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends Tuple2<K3,R>> yieldingFunction) |
<K1,K2,K3,K4,R1,R2,R3,R> |
forEach4(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1,
java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2,
Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends java.lang.Iterable<Tuple2<K3,R3>>> iterable3,
Function4<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? super Tuple2<K3,R3>,? extends Tuple2<K4,R>> yieldingFunction) |
<K1,K2,K3,K4,R1,R2,R3,R> |
forEach4(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1,
java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2,
Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends java.lang.Iterable<Tuple2<K3,R3>>> iterable3,
Function4<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? super Tuple2<K3,R3>,java.lang.Boolean> filterFunction,
Function4<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? super Tuple2<K3,R3>,? extends Tuple2<K4,R>> yieldingFunction) |
static <K,V> HashMap<K,V> |
fromMap(java.util.Map<K,V> map) |
static <K,V> HashMap<K,V> |
fromMap(PersistentMap<K,V> map) |
static <K,V> HashMap<K,V> |
fromStream(java.util.stream.Stream<Tuple2<K,V>> stream) |
Option<V> |
get(K key) |
V |
getOrElse(K key,
V alt) |
V |
getOrElseGet(K key,
java.util.function.Supplier<? extends V> alt) |
int |
hashCode() |
boolean |
isEmpty() |
java.util.Iterator<Tuple2<K,V>> |
iterator() |
<R> HashMap<K,R> |
map(java.util.function.Function<? super V,? extends R> fn)
Transform this functor using the supplied transformation function
|
<R> HashMap<R,V> |
mapKeys(java.util.function.Function<? super K,? extends R> map) |
<R> HashMap<K,R> |
mapValues(java.util.function.Function<? super V,? extends R> map) |
<K2,V2,K3,V3> |
merge(DMap.Two<K2,V2,K3,V3> two) |
<K2,V2> DMap.Two<K,V,K2,V2> |
merge(ImmutableMap<K2,V2> one) |
static <K,V> HashMap<K,V> |
narrow(HashMap<? extends K,? extends V> map) |
HashMap<K,V> |
notNull()
Filter elements retaining only values which are not null
|
static <K,V> HashMap<K,V> |
of(K k,
V v) |
static <K,V> HashMap<K,V> |
of(K k1,
V v1,
K k2,
V v2) |
HashMap<K,V> |
onEmpty(Tuple2<K,V> value)
If this Container instance is zero, create a new instance containing the provided value
|
HashMap<K,V> |
onEmptyGet(java.util.function.Supplier<? extends Tuple2<K,V>> supplier)
If this Container instance is zero, create a new instance containing the value returned from the provided Supplier
|
HashMap<K,V> |
onEmptySwitch(java.util.function.Supplier<? extends ImmutableMap<K,V>> supplier)
Switch to container created by provided Supplier, if current Container zero
|
HashMap<K,V> |
peek(java.util.function.Consumer<? super V> c)
Peek at the current value of this Transformable, without transforming it
|
java.lang.String |
printHAMT() |
HashMap<K,V> |
put(K key,
V value) |
HashMap<K,V> |
put(Tuple2<K,V> keyAndValue) |
HashMap<K,V> |
putAll(PersistentMap<? extends K,? extends V> map) |
HashMap<K,V> |
remove(K key) |
HashMap<K,V> |
removeAll(K... keys) |
HashMap<K,V> |
removeAllKeys(java.lang.Iterable<? extends K> keys) |
int |
size() |
ReactiveSeq<Tuple2<K,V>> |
stream() |
java.lang.String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
containsValue, javaMap, mkString, onEmptyTry, toLazySeq, toSeq
allMatch, anyMatch, atPercentile, bankersQueue, collect, collect, collect, collect, count, countDistinct, doubleStats, elementAt, endsWith, firstValue, foldLeft, foldLeft, foldLeft, foldLeft, foldLeft, foldLeft, foldMap, foldMap, foldMapRight, foldRight, foldRight, foldRight, groupBy, hashSet, headOption, indexOf, indexOfSlice, intStats, iterableTo, join, join, join, lastIndexOf, lastIndexOfSlice, lazySeq, longStats, maxBy, maxBy, maximum, mean, median, minBy, minBy, minimum, mode, noneMatch, nonEmptyList, occurances, populationVariance, print, print, printErr, printOut, scheduleStream, seq, single, single, singleOrElse, startsWith, stdDeviation, sumDouble, sumInt, sumLong, takeOne, toArray, toArray, toCollection, toHashMap, toHashMap, toList, toMap, toMap, toSet, treeSet, variance, vector, withPercentiles, xMatch
equalTo, mapView
public static <K,V> HashMap<K,V> empty()
public static <K,V> HashMap<K,V> of(K k, V v)
public static <K,V> HashMap<K,V> fromMap(java.util.Map<K,V> map)
public static <K,V> HashMap<K,V> fromMap(PersistentMap<K,V> map)
public static <K,V> HashMap<K,V> of(K k1, V v1, K k2, V v2)
public int size()
size
in interface PersistentMap<K,V>
size
in interface ImmutableMap<K,V>
public <K2,V2> DMap.Two<K,V,K2,V2> merge(ImmutableMap<K2,V2> one)
merge
in interface ImmutableMap<K,V>
public <K2,V2,K3,V3> DMap.Three<K,V,K2,V2,K3,V3> merge(DMap.Two<K2,V2,K3,V3> two)
merge
in interface ImmutableMap<K,V>
public ReactiveSeq<Tuple2<K,V>> stream()
public <R> HashMap<K,R> mapValues(java.util.function.Function<? super V,? extends R> map)
mapValues
in interface ImmutableMap<K,V>
public <R> HashMap<R,V> mapKeys(java.util.function.Function<? super K,? extends R> map)
mapKeys
in interface ImmutableMap<K,V>
public <R1,R2> HashMap<R1,R2> bimap(java.util.function.BiFunction<? super K,? super V,? extends Tuple2<R1,R2>> map)
bimap
in interface ImmutableMap<K,V>
public <K2,V2> HashMap<K2,V2> flatMap(java.util.function.BiFunction<? super K,? super V,? extends ImmutableMap<K2,V2>> mapper)
flatMap
in interface ImmutableMap<K,V>
public <K2,V2> HashMap<K2,V2> concatMap(java.util.function.BiFunction<? super K,? super V,? extends java.lang.Iterable<Tuple2<K2,V2>>> mapper)
concatMap
in interface ImmutableMap<K,V>
public HashMap<K,V> filter(java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Filters
of(1,2,3).filter(i->i>2);
//[3]
public HashMap<K,V> filterKeys(java.util.function.Predicate<? super K> predicate)
filterKeys
in interface ImmutableMap<K,V>
public HashMap<K,V> filterValues(java.util.function.Predicate<? super V> predicate)
filterValues
in interface ImmutableMap<K,V>
public <R> HashMap<K,R> map(java.util.function.Function<? super V,? extends R> fn)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
map
in interface Transformable<V>
map
in interface ImmutableMap<K,V>
fn
- Transformation functionpublic <R1,R2> HashMap<R1,R2> bimap(java.util.function.Function<? super K,? extends R1> fn1, java.util.function.Function<? super V,? extends R2> fn2)
BiTransformable
MapX<String,Integer> map = MapXs.of("hello",2);
MapX<String,Integer> transformedMap = map.bimap(s->s+" world",i->i*4);
//["hello world",8]
bimap
in interface BiTransformable<K,V>
bimap
in interface ImmutableMap<K,V>
fn1
- transformation function for the first typefn2
- transformation function for the second typepublic HashMap<K,V> put(K key, V value)
put
in interface PersistentMap<K,V>
put
in interface ImmutableMap<K,V>
public HashMap<K,V> put(Tuple2<K,V> keyAndValue)
put
in interface PersistentMap<K,V>
put
in interface ImmutableMap<K,V>
public HashMap<K,V> remove(K key)
remove
in interface PersistentMap<K,V>
remove
in interface ImmutableMap<K,V>
public HashMap<K,V> removeAll(K... keys)
removeAll
in interface ImmutableMap<K,V>
public boolean isEmpty()
isEmpty
in interface PersistentMap<K,V>
isEmpty
in interface ImmutableMap<K,V>
public boolean containsKey(K key)
containsKey
in interface PersistentMap<K,V>
containsKey
in interface ImmutableMap<K,V>
public boolean contains(Tuple2<K,V> t)
contains
in interface ImmutableMap<K,V>
public Option<V> get(K key)
get
in interface PersistentMap<K,V>
get
in interface ImmutableMap<K,V>
public V getOrElse(K key, V alt)
getOrElse
in interface PersistentMap<K,V>
getOrElse
in interface ImmutableMap<K,V>
public V getOrElseGet(K key, java.util.function.Supplier<? extends V> alt)
getOrElseGet
in interface PersistentMap<K,V>
getOrElseGet
in interface ImmutableMap<K,V>
public HashMap<K,V> putAll(PersistentMap<? extends K,? extends V> map)
putAll
in interface PersistentMap<K,V>
putAll
in interface ImmutableMap<K,V>
public HashMap<K,V> removeAllKeys(java.lang.Iterable<? extends K> keys)
removeAllKeys
in interface PersistentMap<K,V>
removeAllKeys
in interface ImmutableMap<K,V>
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public HashMap<K,V> filterNot(java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Filters
of(1,2,3).filter(i->i>2);
//[1,2]
public HashMap<K,V> notNull()
Filters
of(1,2,null,4).nonNull();
//[1,2,4]
public HashMap<K,V> peek(java.util.function.Consumer<? super V> c)
Transformable
of(1,2,3).map(System.out::println)
1
2
3
peek
in interface Transformable<V>
peek
in interface ImmutableMap<K,V>
c
- Consumer that recieves each element from this Transformablepublic HashMap<K,V> bipeek(java.util.function.Consumer<? super K> c1, java.util.function.Consumer<? super V> c2)
BiTransformable
MapX<String,Integer> map = MapXs.of("hello",2);
map.bipeek(s->System.out.pritnln("key = " + s),System.out::println);
bipeek
in interface BiTransformable<K,V>
bipeek
in interface ImmutableMap<K,V>
c1
- consumer for the first typec2
- consumer for the second typepublic HashMap<K,V> onEmpty(Tuple2<K,V> value)
OnEmpty
public HashMap<K,V> onEmptyGet(java.util.function.Supplier<? extends Tuple2<K,V>> supplier)
OnEmpty
onEmptyGet
in interface OnEmpty<Tuple2<K,V>>
onEmptyGet
in interface ImmutableMap<K,V>
supplier
- to determine new value for containerpublic HashMap<K,V> onEmptySwitch(java.util.function.Supplier<? extends ImmutableMap<K,V>> supplier)
OnEmptySwitch
Seq.zero().onEmptySwitch(()->Seq.of(1));
onEmptySwitch
in interface OnEmptySwitch<Tuple2<K,V>,ImmutableMap<K,V>>
onEmptySwitch
in interface ImmutableMap<K,V>
supplier
- to create replacement containerpublic <K1,K2,K3,K4,R1,R2,R3,R> HashMap<K4,R> forEach4(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1, java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2, Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends java.lang.Iterable<Tuple2<K3,R3>>> iterable3, Function4<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? super Tuple2<K3,R3>,? extends Tuple2<K4,R>> yieldingFunction)
forEach4
in interface ImmutableMap<K,V>
public <K1,K2,K3,K4,R1,R2,R3,R> HashMap<K4,R> forEach4(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1, java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2, Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends java.lang.Iterable<Tuple2<K3,R3>>> iterable3, Function4<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? super Tuple2<K3,R3>,java.lang.Boolean> filterFunction, Function4<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? super Tuple2<K3,R3>,? extends Tuple2<K4,R>> yieldingFunction)
forEach4
in interface ImmutableMap<K,V>
public <K1,K2,K3,R1,R2,R> HashMap<K3,R> forEach3(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1, java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2, Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends Tuple2<K3,R>> yieldingFunction)
forEach3
in interface ImmutableMap<K,V>
public <K1,K2,K3,R1,R2,R> HashMap<K3,R> forEach3(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1, java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2, Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,java.lang.Boolean> filterFunction, Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends Tuple2<K3,R>> yieldingFunction)
forEach3
in interface ImmutableMap<K,V>
public <K1,K2,R1,R> HashMap<K2,R> forEach2(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1, java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends Tuple2<K2,R>> yieldingFunction)
forEach2
in interface ImmutableMap<K,V>
public <K1,K2,R1,R> HashMap<K2,R> forEach2(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1, java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,java.lang.Boolean> filterFunction, java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends Tuple2<K2,R>> yieldingFunction)
forEach2
in interface ImmutableMap<K,V>
public java.lang.String printHAMT()