public final class TreeMap<K,V> extends java.lang.Object implements ImmutableMap<K,V>, Higher2<DataWitness.treeMap,K,V>, java.io.Serializable
Constructor and Description |
---|
TreeMap() |
Modifier and Type | Method and Description |
---|---|
<R1,R2> TreeMap<R1,R2> |
bimap(java.util.function.BiFunction<? super K,? super V,? extends Tuple2<R1,R2>> map) |
<R1,R2> TreeMap<R1,R2> |
bimap(java.util.function.BiFunction<? super K,? super V,? extends Tuple2<R1,R2>> map,
java.util.Comparator<R1> comp) |
<KR,VR> TreeMap<KR,VR> |
bimap(java.util.Comparator<KR> comp,
java.util.function.Function<? super K,? extends KR> keyMapper,
java.util.function.Function<? super V,? extends VR> valueMapper) |
<R1,R2> TreeMap<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.
|
<R1,R2> TreeMap<R1,R2> |
bimap(java.util.function.Function<? super K,? extends R1> fn1,
java.util.function.Function<? super V,? extends R2> fn2,
java.util.Comparator<K> comp) |
TreeMap<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> TreeMap<K2,V2> |
concatMap(java.util.function.BiFunction<? super K,? super V,? extends java.lang.Iterable<Tuple2<K2,V2>>> mapper) |
<K2,V2> TreeMap<K2,V2> |
concatMap(java.util.function.BiFunction<? super K,? super V,? extends java.lang.Iterable<Tuple2<K2,V2>>> mapper,
java.util.Comparator<K2> comp) |
boolean |
contains(Tuple2<K,V> t) |
boolean |
containsKey(K key) |
static <K,V> TreeMap<K,V> |
empty(java.util.Comparator<K> comp) |
boolean |
equals(java.lang.Object o) |
TreeMap<K,V> |
filter(java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Keep only elements for which the supplied predicates hold
e.g.
|
TreeMap<K,V> |
filterKeys(java.util.function.Predicate<? super K> predicate) |
TreeMap<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.
|
TreeMap<K,V> |
filterValues(java.util.function.Predicate<? super V> predicate) |
<K2,V2> TreeMap<K2,V2> |
flatMap(java.util.function.BiFunction<? super K,? super V,? extends ImmutableMap<K2,V2>> mapper) |
<K2,V2> TreeMap<K2,V2> |
flatMap(java.util.function.BiFunction<? super K,? super V,? extends ImmutableMap<K2,V2>> mapper,
java.util.Comparator<K2> comp) |
<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> TreeMap<K,V> |
fromMap(java.util.Comparator<K> comp,
java.util.Map<K,V> map) |
static <K,V> TreeMap<K,V> |
fromMap(java.util.Comparator<K> comp,
PersistentMap<K,V> map) |
static <K,V> TreeMap<K,V> |
fromStream(java.util.stream.Stream<Tuple2<K,V>> stream,
java.util.Comparator<K> comp) |
Option<V> |
get(K key) |
V |
getOrElse(K key,
V alt) |
V |
getOrElseGet(K key,
java.util.function.Supplier<? extends V> alt) |
int |
hashCode() |
java.util.Iterator<Tuple2<K,V>> |
iterator() |
<R> TreeMap<K,R> |
map(java.util.function.Function<? super V,? extends R> fn)
Transform this functor using the supplied transformation function
|
<R> TreeMap<R,V> |
mapKeys(java.util.function.Function<? super K,? extends R> map) |
<R> TreeMap<R,V> |
mapKeys(java.util.function.Function<? super K,? extends R> map,
java.util.Comparator<R> comp) |
<R> TreeMap<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) |
TreeMap<K,V> |
notNull()
Filter elements retaining only values which are not null
|
static <K,V> TreeMap<K,V> |
of(java.util.Comparator<K> comp,
K k,
V v) |
static <K,V> TreeMap<K,V> |
of(java.util.Comparator<K> comp,
K k1,
V v1,
K k2,
V v2) |
TreeMap<K,V> |
onEmpty(Tuple2<K,V> value)
If this Container instance is zero, create a new instance containing the provided value
|
TreeMap<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
|
TreeMap<K,V> |
onEmptySwitch(java.util.function.Supplier<? extends ImmutableMap<K,V>> supplier)
Switch to container created by provided Supplier, if current Container zero
|
TreeMap<K,V> |
peek(java.util.function.Consumer<? super V> c)
Peek at the current value of this Transformable, without transforming it
|
TreeMap<K,V> |
put(K key,
V value) |
TreeMap<K,V> |
put(Tuple2<K,V> keyAndValue) |
TreeMap<K,V> |
putAll(PersistentMap<? extends K,? extends V> map) |
TreeMap<K,V> |
remove(K key) |
TreeMap<K,V> |
removeAll(K... keys) |
int |
size() |
ReactiveSeq<Tuple2<K,V>> |
stream() |
java.lang.String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
allMatch, containsValue, isEmpty, javaMap, keys, mkString, onEmptyTry, removeAllKeys, toLazySeq, toSeq, values
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 ReactiveSeq<Tuple2<K,V>> stream()
public static <K,V> TreeMap<K,V> empty(java.util.Comparator<K> comp)
public static <K,V> TreeMap<K,V> of(java.util.Comparator<K> comp, K k, V v)
public static <K,V> TreeMap<K,V> of(java.util.Comparator<K> comp, K k1, V v1, K k2, V v2)
public static <K,V> TreeMap<K,V> fromStream(java.util.stream.Stream<Tuple2<K,V>> stream, java.util.Comparator<K> comp)
public <R> TreeMap<K,R> mapValues(java.util.function.Function<? super V,? extends R> map)
mapValues
in interface ImmutableMap<K,V>
public <R> TreeMap<R,V> mapKeys(java.util.function.Function<? super K,? extends R> map)
mapKeys
in interface ImmutableMap<K,V>
public <R1,R2> TreeMap<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> TreeMap<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> TreeMap<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 <R> TreeMap<R,V> mapKeys(java.util.function.Function<? super K,? extends R> map, java.util.Comparator<R> comp)
public <R1,R2> TreeMap<R1,R2> bimap(java.util.function.BiFunction<? super K,? super V,? extends Tuple2<R1,R2>> map, java.util.Comparator<R1> comp)
public <K2,V2> TreeMap<K2,V2> flatMap(java.util.function.BiFunction<? super K,? super V,? extends ImmutableMap<K2,V2>> mapper, java.util.Comparator<K2> comp)
public <K2,V2> TreeMap<K2,V2> concatMap(java.util.function.BiFunction<? super K,? super V,? extends java.lang.Iterable<Tuple2<K2,V2>>> mapper, java.util.Comparator<K2> comp)
public TreeMap<K,V> filter(java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Filters
of(1,2,3).filter(i->i>2);
//[3]
public TreeMap<K,V> filterKeys(java.util.function.Predicate<? super K> predicate)
filterKeys
in interface ImmutableMap<K,V>
public TreeMap<K,V> filterValues(java.util.function.Predicate<? super V> predicate)
filterValues
in interface ImmutableMap<K,V>
public <R> TreeMap<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> TreeMap<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 <R1,R2> TreeMap<R1,R2> bimap(java.util.function.Function<? super K,? extends R1> fn1, java.util.function.Function<? super V,? extends R2> fn2, java.util.Comparator<K> comp)
public static <K,V> TreeMap<K,V> fromMap(java.util.Comparator<K> comp, java.util.Map<K,V> map)
public static <K,V> TreeMap<K,V> fromMap(java.util.Comparator<K> comp, PersistentMap<K,V> map)
public <KR,VR> TreeMap<KR,VR> bimap(java.util.Comparator<KR> comp, java.util.function.Function<? super K,? extends KR> keyMapper, java.util.function.Function<? super V,? extends VR> valueMapper)
public TreeMap<K,V> put(K key, V value)
put
in interface PersistentMap<K,V>
put
in interface ImmutableMap<K,V>
public TreeMap<K,V> put(Tuple2<K,V> keyAndValue)
put
in interface PersistentMap<K,V>
put
in interface ImmutableMap<K,V>
public TreeMap<K,V> putAll(PersistentMap<? extends K,? extends V> map)
putAll
in interface PersistentMap<K,V>
putAll
in interface ImmutableMap<K,V>
public TreeMap<K,V> remove(K key)
remove
in interface PersistentMap<K,V>
remove
in interface ImmutableMap<K,V>
public TreeMap<K,V> removeAll(K... keys)
removeAll
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 PersistentMap<K,V>
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 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 java.lang.String toString()
toString
in class java.lang.Object
public TreeMap<K,V> filterNot(java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Filters
of(1,2,3).filter(i->i>2);
//[1,2]
public TreeMap<K,V> notNull()
Filters
of(1,2,null,4).nonNull();
//[1,2,4]
public TreeMap<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 TreeMap<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 TreeMap<K,V> onEmpty(Tuple2<K,V> value)
OnEmpty
public TreeMap<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 TreeMap<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> TreeMap<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> TreeMap<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> TreeMap<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> TreeMap<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> TreeMap<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> TreeMap<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 boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object