Top Description Inners Fields Constructors Methods
io.vavr.collection

public final Class TreeMap<K, V>

extends Object
implements SortedMap<K, V>, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, io.vavr.collection.SortedMap, io.vavr.collection.Ordered, io.vavr.collection.Map, io.vavr.PartialFunction, io.vavr.Function1, java.util.function.Function, io.vavr.collection.Traversable, io.vavr.Value, java.lang.Iterable, io.vavr.collection.Foldable
Type Parameters
<K>
Key type
<V>
Value type
Imports
io.vavr.Tuple, .Tuple2, io.vavr.control.Option, java.io.Serializable, java.util.ArrayList, .Comparator, .NoSuchElementException, .Objects, java.util.function.*, java.util.stream.Collector

SortedMap implementation, backed by a Red/Black Tree.
Author
Daniel Dietrich

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static interface

Field Summary

Modifier and TypeField and Description
private final RedBlackTree<Tuple2<K, V>>
private static final long

Constructor Summary

AccessConstructor and Description
private
TreeMap(RedBlackTree<Tuple2<K, V>> entries)

Method Summary

Modifier and TypeMethod and Description
public <K2, V2> TreeMap<K2, V2>
bimap(Function<? super K, ? extends K2>
a Function that maps the keys of type K to keys of type K2
keyMapper
,
Function<? super V, ? extends V2>
a Function that the values of type V to values of type V2
valueMapper
)

Implements io.vavr.collection.SortedMap.bimap.

Maps this Map to a new Map with different component type by applying a function to its elements.

public <K2, V2> TreeMap<K2, V2>
bimap(Comparator<? super K2>
A comparator for keys of type K2
keyComparator
,
Function<? super K, ? extends K2>
a Function that maps the keys of type K to keys of type K2
keyMapper
,
Function<? super V, ? extends V2>
a Function that the values of type V to values of type V2
valueMapper
)

Implements io.vavr.collection.SortedMap.bimap.

Same as bimap(Function, Function), using a specific comparator for keys of the codomain of the given keyMapper.

private static <K, K2, V, V2> TreeMap<K2, V2>
bimap(TreeMap<K, V> map, TreeMap.EntryComparator<K2, V2> entryComparator, Function<? super K, ? extends K2> keyMapper, Function<? super V, ? extends V2> valueMapper)

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
Collector<Tuple2<K, V>, ArrayList<Tuple2<K, V>>, TreeMap<K, V>>

Returns:

A TreeMap Collector.
collector
()

Returns a Collector which may be used in conjunction with java.util.stream.Stream#collect(Collector) to obtain a TreeMap.

public static <
The key type
K
,
The value type
V
>
Collector<Tuple2<K, V>, ArrayList<Tuple2<K, V>>, TreeMap<K, V>>

Returns:

A TreeMap Collector.
collector
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
)

Returns a Collector which may be used in conjunction with java.util.stream.Stream#collect(Collector) to obtain a TreeMap.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
,
Initial java.util.stream.Stream elements type
T extends V
>
Collector<T, ArrayList<T>, TreeMap<K, V>>

Returns:

A TreeMap Collector.
collector
(Function<? super T, ? extends K>
The key mapper
keyMapper
)

Returns a java.util.stream.Collector which may be used in conjunction with java.util.stream.Stream#collect(java.util.stream.Collector) to obtain a TreeMap.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
,
Initial java.util.stream.Stream elements type
T
>
Collector<T, ArrayList<T>, TreeMap<K, V>>

Returns:

A TreeMap Collector.
collector
(Function<? super T, ? extends K>
The key mapper
keyMapper
,
Function<? super T, ? extends V>
The value mapper
valueMapper
)

Returns a java.util.stream.Collector which may be used in conjunction with java.util.stream.Stream#collect(java.util.stream.Collector) to obtain a TreeMap.

public static <
The key type
K
,
The value type
V
,
Initial java.util.stream.Stream elements type
T extends V
>
Collector<T, ArrayList<T>, TreeMap<K, V>>

Returns:

A TreeMap Collector.
collector
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
Function<? super T, ? extends K>
The key mapper
keyMapper
)

Returns a java.util.stream.Collector which may be used in conjunction with java.util.stream.Stream#collect(java.util.stream.Collector) to obtain a TreeMap.

public static <
The key type
K
,
The value type
V
,
Initial java.util.stream.Stream elements type
T
>
Collector<T, ArrayList<T>, TreeMap<K, V>>

Returns:

A TreeMap Collector.
collector
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
Function<? super T, ? extends K>
The key mapper
keyMapper
,
Function<? super T, ? extends V>
The value mapper
valueMapper
)

Returns a java.util.stream.Collector which may be used in conjunction with java.util.stream.Stream#collect(java.util.stream.Collector) to obtain a TreeMap.

public Comparator<K>
comparator()

Implements io.vavr.collection.Ordered.comparator.

Returns the comparator which defines the order of the elements contained in this collection.

public Tuple2<V, TreeMap<K, V>>
computeIfAbsent(K
key whose presence in this map is to be tested
key
,
Function<? super K, ? extends V>
mapping function
mappingFunction
)

Implements io.vavr.collection.SortedMap.computeIfAbsent.

If the specified key is not already associated with a value, attempts to compute its value using the given mapping function and enters it into this map.

public Tuple2<Option<V>, TreeMap<K, V>>
computeIfPresent(K
key whose presence in this map is to be tested
key
,
BiFunction<? super K, ? super V, ? extends V>
remapping function
remappingFunction
)

Implements io.vavr.collection.SortedMap.computeIfPresent.

If the value for the specified key is present, attempts to compute a new mapping given the key and its current mapped value.

public boolean
containsKey(K
key whose presence in this map is to be tested
key
)

Implements io.vavr.collection.Map.containsKey.

Returns true if this map contains a mapping for the specified key.

private static <K, V> Collector<Tuple2<K, V>, ArrayList<Tuple2<K, V>>, TreeMap<K, V>>
createCollector(TreeMap.EntryComparator<K, V> entryComparator)

private static <K, V, T> Collector<T, ArrayList<T>, TreeMap<K, V>>
createCollector(TreeMap.EntryComparator<K, V> entryComparator, Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper)

private TreeMap<K, V>
private static <K, V> TreeMap<K, V>
createFromMap(TreeMap.EntryComparator<K, V> entryComparator, Map<? extends K, ? extends V> map)

private static <K, V> TreeMap<K, V>
createFromMapEntries(TreeMap.EntryComparator<K, V> entryComparator, Map.Entry<? extends K, ? extends V>... entries)

private static <K, V> TreeMap<K, V>
createFromPairs(TreeMap.EntryComparator<K, V> entryComparator, Object... pairs)

private static <K, V> TreeMap<K, V>
createFromTuple(TreeMap.EntryComparator<K, V> entryComparator, Tuple2<? extends K, ? extends V> entry)

private static <K, V> TreeMap<K, V>
createFromTuples(TreeMap.EntryComparator<K, V> entryComparator, Tuple2<? extends K, ? extends V>... entries)

private static <K, V> TreeMap<K, V>
createTreeMap(TreeMap.EntryComparator<K, V> entryComparator, Iterable<? extends Tuple2<? extends K, ? extends V>> entries)

private static <K, K2, V, V2> TreeMap<K2, V2>
createTreeMap(TreeMap.EntryComparator<K2, V2> entryComparator, Iterable<Tuple2<K, V>> entries, Function<Tuple2<K, V>, Tuple2<K2, V2>> entryMapper)

public TreeMap<K, V>
distinct()

Implements io.vavr.collection.SortedMap.distinct.

Returns a new version of this which contains no duplicates.

public TreeMap<K, V>
distinctBy(Comparator<? super Tuple2<K, V>>
A comparator
comparator
)

Implements io.vavr.collection.SortedMap.distinctBy.

Returns a new version of this which contains no duplicates.

public <U> TreeMap<K, V>
distinctBy(Function<? super Tuple2<K, V>, ? extends U>
A key extractor
keyExtractor
)

Implements io.vavr.collection.SortedMap.distinctBy.

Returns a new version of this which contains no duplicates.

public TreeMap<K, V>
drop(int
The number of elements to drop.
n
)

Implements io.vavr.collection.SortedMap.drop.

Drops the first n elements of this or all elements, if this length < n.

public TreeMap<K, V>
dropRight(int
The number of elements to drop.
n
)

Implements io.vavr.collection.SortedMap.dropRight.

Drops the last n elements of this or all elements, if this length < n.

public TreeMap<K, V>
dropUntil(Predicate<? super Tuple2<K, V>>
A condition tested subsequently for this elements.
predicate
)

Implements io.vavr.collection.SortedMap.dropUntil.

Drops elements until the predicate holds for the current element.

public TreeMap<K, V>
dropWhile(Predicate<? super Tuple2<K, V>>
A condition tested subsequently for this elements.
predicate
)

Implements io.vavr.collection.SortedMap.dropWhile.

Drops elements while the predicate holds for the current element.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new empty TreeMap.
empty
()

Returns the empty TreeMap.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new empty TreeMap.
empty
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
)

Returns the empty TreeMap using the given key comparator.

private TreeMap<K, V>
public boolean
equals(Object
an object, may be null
o
)

Overrides java.lang.Object.equals.

Implements io.vavr.collection.Traversable.equals.

In Vavr there are four basic classes of collections:

  • Seq (sequential elements)
  • Set (distinct elements)
  • Map (indexed elements)
  • Multimap (indexed collections)
public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A TreeMap of size n, where each element contains the result supplied by s.
fill
(Comparator<? super K>
The comparator used to sort the entries by their key
keyComparator
,
int
The number of elements in the TreeMap
n
,
Supplier<? extends Tuple2<? extends K, ? extends V>>
The Supplier computing element values
s
)

Returns a TreeMap containing tuples returned by n calls to a given Supplier s.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A TreeMap of size n, where each element contains the result supplied by s.
fill
(int
The number of elements in the TreeMap
n
,
Supplier<? extends Tuple2<? extends K, ? extends V>>
The Supplier computing element values
s
)

Returns a TreeMap containing tuples returned by n calls to a given Supplier s.

public TreeMap<K, V>
filter(BiPredicate<? super K, ? super V>
the predicate used to test elements
predicate
)

Implements io.vavr.collection.SortedMap.filter.

Returns a new Map consisting of all elements which satisfy the given predicate.

public TreeMap<K, V>
filter(Predicate<? super Tuple2<K, V>>
A predicate
predicate
)

Implements io.vavr.collection.SortedMap.filter.

Returns a new traversable consisting of all elements which satisfy the given predicate.

public TreeMap<K, V>
filterKeys(Predicate<? super K>
the predicate used to test keys of elements
predicate
)

Implements io.vavr.collection.SortedMap.filterKeys.

Returns a new Map consisting of all elements with keys which satisfy the given predicate.

public TreeMap<K, V>
filterValues(Predicate<? super V>
the predicate used to test values of elements
predicate
)

Implements io.vavr.collection.SortedMap.filterValues.

Returns a new Map consisting of all elements with values which satisfy the given predicate.

public <K2, V2> TreeMap<K2, V2>
flatMap(BiFunction<? super K, ? super V, ? extends Iterable<Tuple2<K2, V2>>>
A mapper
mapper
)

Implements io.vavr.collection.SortedMap.flatMap.

FlatMaps this Map to a new Map with different component type.

public <K2, V2> TreeMap<K2, V2>
flatMap(Comparator<? super K2>
A comparator for keys of type U
keyComparator
,
BiFunction<? super K, ? super V, ? extends Iterable<Tuple2<K2, V2>>>
A function which maps key/value pairs to Iterables map entries
mapper
)

Implements io.vavr.collection.SortedMap.flatMap.

Same as flatMap(BiFunction) but using a specific comparator for values of the codomain of the given mapper.

private static <K, V, K2, V2> TreeMap<K2, V2>
flatMap(TreeMap<K, V> map, TreeMap.EntryComparator<K2, V2> entryComparator, BiFunction<? super K, ? super V, ? extends Iterable<Tuple2<K2, V2>>> mapper)

public Option<V>
get(K
the key whose associated value is to be returned
key
)

Implements io.vavr.collection.Map.get.

Returns the Some of value to which the specified key is mapped, or None if this map contains no mapping for the key.

public V
getOrElse(K
the key
key
,
V
a default value
defaultValue
)

Implements io.vavr.collection.Map.getOrElse.

Returns the value associated with a key, or a default value if the key is not contained in the map.

public <C> Map<C, TreeMap<K, V>>
groupBy(Function<? super Tuple2<K, V>, ? extends C>
A function which classifies elements into classes
classifier
)

Implements io.vavr.collection.SortedMap.groupBy.

Groups this elements by classifying the elements.

public Iterator<TreeMap<K, V>>
grouped(int
a positive block size
size
)

Implements io.vavr.collection.SortedMap.grouped.

Groups this Traversable into fixed size blocks.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Implements io.vavr.collection.Traversable.hashCode.

Returns the hash code of this collection.

public Tuple2<K, V>
head()

Implements io.vavr.collection.Traversable.head.

Returns the first element of a non-empty Traversable.

public TreeMap<K, V>
init()

Implements io.vavr.collection.SortedMap.init.

Dual of tail(), returning all elements except the last.

public Option<TreeMap<K, V>>
initOption()

Implements io.vavr.collection.SortedMap.initOption.

Dual of tailOption(), returning all elements except the last as Option.

public boolean

Returns:

false
isAsync
()

Implements io.vavr.Value.isAsync.

An TreeMap's value is computed synchronously.

public boolean
isEmpty()

Overrides default io.vavr.collection.Traversable.isEmpty.

Checks if this Traversable is empty.

public boolean

Returns:

false
isLazy
()

Implements io.vavr.Value.isLazy.

An TreeMap's value is computed eagerly.

public Iterator<Tuple2<K, V>>
iterator()

Implements io.vavr.collection.Map.iterator.

An iterator by means of head() and tail().

public SortedSet<K>
keySet()

Implements io.vavr.collection.SortedMap.keySet.

Returns the keys contained in this map.

public Tuple2<K, V>
last()

Overrides default io.vavr.collection.SortedMap.last.

Dual of head(), returning the last element.

public <K2, V2> TreeMap<K2, V2>
map(BiFunction<? super K, ? super V, Tuple2<K2, V2>>
a Function that maps entries of type (K, V) to entries of type (K2, V2)
mapper
)

Implements io.vavr.collection.SortedMap.map.

Maps the entries of this Map to form a new Map.

public <K2, V2> TreeMap<K2, V2>
map(Comparator<? super K2>
A comparator for keys of type U
keyComparator
,
BiFunction<? super K, ? super V, Tuple2<K2, V2>>
a Function that maps entries of type (K, V) to entries of type (K2, V2)
mapper
)

Implements io.vavr.collection.SortedMap.map.

Same as map(BiFunction), using a specific comparator for keys of the codomain of the given mapper.

private static <K, K2, V, V2> TreeMap<K2, V2>
map(TreeMap<K, V> map, TreeMap.EntryComparator<K2, V2> entryComparator, BiFunction<? super K, ? super V, Tuple2<K2, V2>> mapper)

public <K2> TreeMap<K2, V>
mapKeys(Function<? super K, ? extends K2>
a Function that maps keys of type V to keys of type V2
keyMapper
)

Implements io.vavr.collection.SortedMap.mapKeys.

Maps the keys of this Map while preserving the corresponding values.

public <K2> TreeMap<K2, V>
mapKeys(Function<? super K, ? extends K2>
a Function that maps keys of type V to keys of type V2
keyMapper
,
BiFunction<? super V, ? super V, ? extends V>
a BiFunction that merges values
valueMerge
)

Implements io.vavr.collection.SortedMap.mapKeys.

Maps the keys of this Map while preserving the corresponding values and applying a value merge function on collisions.

public <W> TreeMap<K, W>
mapValues(Function<? super V, ? extends W>
a Function that maps values of type V to values of type V2
valueMapper
)

Implements io.vavr.collection.SortedMap.mapValues.

Maps the values of this Map while preserving the corresponding keys.

public TreeMap<K, V>
merge(Map<? extends K, ? extends V>
the other map
that
)

Implements io.vavr.collection.SortedMap.merge.

Creates a new map which by merging the entries of this map and that map.

public <U extends V> TreeMap<K, V>
merge(Map<? extends K, U>
the other map
that
,
BiFunction<? super V, ? super U, ? extends V>
the collision resolution function
collisionResolution
)

Implements io.vavr.collection.SortedMap.merge.

Creates a new map which by merging the entries of this map and that map.

public static <
Key type
K
,
Value type
V
>
TreeMap<K, V>

Returns:

the given treeMap instance as narrowed type TreeMap<K, V>.
narrow
(TreeMap<? extends K, ? extends V>
A TreeMap.
treeMap
)

Narrows a widened TreeMap<?

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new TreeMap containing the given entry.
of
(Tuple2<? extends K, ? extends V>
A map entry.
entry
)

Returns a singleton TreeMap, i.e. a TreeMap of one entry.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new TreeMap containing the given entry.
of
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
Tuple2<? extends K, ? extends V>
A map entry.
entry
)

Returns a singleton TreeMap, i.e. a TreeMap of one entry using a specific key comparator.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entry
of
(K
A singleton map key.
key
,
V
A singleton map value.
value
)

Returns a singleton TreeMap, i.e. a TreeMap of one element.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
,
K
a key for the map
k4
,
V
the value for k4
v4
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
,
K
a key for the map
k4
,
V
the value for k4
v4
,
K
a key for the map
k5
,
V
the value for k5
v5
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
,
K
a key for the map
k4
,
V
the value for k4
v4
,
K
a key for the map
k5
,
V
the value for k5
v5
,
K
a key for the map
k6
,
V
the value for k6
v6
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
,
K
a key for the map
k4
,
V
the value for k4
v4
,
K
a key for the map
k5
,
V
the value for k5
v5
,
K
a key for the map
k6
,
V
the value for k6
v6
,
K
a key for the map
k7
,
V
the value for k7
v7
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
,
K
a key for the map
k4
,
V
the value for k4
v4
,
K
a key for the map
k5
,
V
the value for k5
v5
,
K
a key for the map
k6
,
V
the value for k6
v6
,
K
a key for the map
k7
,
V
the value for k7
v7
,
K
a key for the map
k8
,
V
the value for k8
v8
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
,
K
a key for the map
k4
,
V
the value for k4
v4
,
K
a key for the map
k5
,
V
the value for k5
v5
,
K
a key for the map
k6
,
V
the value for k6
v6
,
K
a key for the map
k7
,
V
the value for k7
v7
,
K
a key for the map
k8
,
V
the value for k8
v8
,
K
a key for the map
k9
,
V
the value for k9
v9
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
,
K
a key for the map
k4
,
V
the value for k4
v4
,
K
a key for the map
k5
,
V
the value for k5
v5
,
K
a key for the map
k6
,
V
the value for k6
v6
,
K
a key for the map
k7
,
V
the value for k7
v7
,
K
a key for the map
k8
,
V
the value for k8
v8
,
K
a key for the map
k9
,
V
the value for k9
v9
,
K
a key for the map
k10
,
V
the value for k10
v10
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entry
of
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
K
A singleton map key.
key
,
V
A singleton map value.
value
)

Returns a singleton TreeMap, i.e. a TreeMap of one element.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
,
K
a key for the map
k4
,
V
the value for k4
v4
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
,
K
a key for the map
k4
,
V
the value for k4
v4
,
K
a key for the map
k5
,
V
the value for k5
v5
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
,
K
a key for the map
k4
,
V
the value for k4
v4
,
K
a key for the map
k5
,
V
the value for k5
v5
,
K
a key for the map
k6
,
V
the value for k6
v6
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
,
K
a key for the map
k4
,
V
the value for k4
v4
,
K
a key for the map
k5
,
V
the value for k5
v5
,
K
a key for the map
k6
,
V
the value for k6
v6
,
K
a key for the map
k7
,
V
the value for k7
v7
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
,
K
a key for the map
k4
,
V
the value for k4
v4
,
K
a key for the map
k5
,
V
the value for k5
v5
,
K
a key for the map
k6
,
V
the value for k6
v6
,
K
a key for the map
k7
,
V
the value for k7
v7
,
K
a key for the map
k8
,
V
the value for k8
v8
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
,
K
a key for the map
k4
,
V
the value for k4
v4
,
K
a key for the map
k5
,
V
the value for k5
v5
,
K
a key for the map
k6
,
V
the value for k6
v6
,
K
a key for the map
k7
,
V
the value for k7
v7
,
K
a key for the map
k8
,
V
the value for k8
v8
,
K
a key for the map
k9
,
V
the value for k9
v9
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given entries
of
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
K
a key for the map
k1
,
V
the value for k1
v1
,
K
a key for the map
k2
,
V
the value for k2
v2
,
K
a key for the map
k3
,
V
the value for k3
v3
,
K
a key for the map
k4
,
V
the value for k4
v4
,
K
a key for the map
k5
,
V
the value for k5
v5
,
K
a key for the map
k6
,
V
the value for k6
v6
,
K
a key for the map
k7
,
V
the value for k7
v7
,
K
a key for the map
k8
,
V
the value for k8
v8
,
K
a key for the map
k9
,
V
the value for k9
v9
,
K
a key for the map
k10
,
V
the value for k10
v10
)

Creates a TreeMap of the given list of key-value pairs.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given map
ofAll
(Map<? extends K, ? extends V>
A map
map
)

Returns a TreeMap, from a source java.util.Map.

public static <
The stream element type
T
,
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map
ofAll
(Stream<? extends T>
the source stream
stream
,
Function<? super T, ? extends K>
the key mapper
keyMapper
,
Function<? super T, ? extends V>
the value mapper
valueMapper
)

Returns a TreeMap, from entries mapped from stream.

public static <
The stream element type
T
,
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map
ofAll
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
Stream<? extends T>
the source stream
stream
,
Function<? super T, ? extends K>
the key mapper
keyMapper
,
Function<? super T, ? extends V>
the value mapper
valueMapper
)

Returns a TreeMap, from entries mapped from stream.

public static <
The stream element type
T
,
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map
ofAll
(Stream<? extends T>
the source stream
stream
,
Function<? super T, Tuple2<? extends K, ? extends V>>
the entry mapper
entryMapper
)

Returns a TreeMap, from entries mapped from stream.

public static <
The stream element type
T
,
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map
ofAll
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
Stream<? extends T>
the source stream
stream
,
Function<? super T, Tuple2<? extends K, ? extends V>>
the entry mapper
entryMapper
)

Returns a TreeMap, from entries mapped from stream.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new Map containing the given map
ofAll
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
Map<? extends K, ? extends V>
A map
map
)

Returns a TreeMap, from a source java.util.Map.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new TreeMap containing the given entries.
ofEntries
(Tuple2<? extends K, ? extends V>...
Map entries
entries
)

Creates a TreeMap of the given entries using the natural key comparator.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new TreeMap containing the given entries.
ofEntries
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
Tuple2<? extends K, ? extends V>...
Map entries
entries
)

Creates a TreeMap of the given entries using the given key comparator.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new TreeMap containing the given entries.
ofEntries
(Map.Entry<? extends K, ? extends V>...
Map entries
entries
)

Creates a TreeMap of the given entries using the natural key comparator.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new TreeMap containing the given entries.
ofEntries
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
Map.Entry<? extends K, ? extends V>...
Map entries
entries
)

Creates a TreeMap of the given entries using the given key comparator.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A new TreeMap containing the given entries.
ofEntries
(Iterable<? extends Tuple2<? extends K, ? extends V>>
Map entries
entries
)

Creates a TreeMap of the given entries.

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A new TreeMap containing the given entries.
ofEntries
(Comparator<? super K>
The comparator used to sort the entries by their key.
keyComparator
,
Iterable<? extends Tuple2<? extends K, ? extends V>>
Map entries
entries
)

Creates a TreeMap of the given entries.

public TreeMap<K, V>

Returns:

this TreeMap if it is nonempty, otherwise TreeMap created from iterable, using existing comparator.
orElse
(Iterable<? extends Tuple2<K, V>>
An alternative Traversable
other
)

Implements io.vavr.collection.SortedMap.orElse.

Returns this TreeMap if it is nonempty, otherwise TreeMap created from iterable, using existing comparator.

public TreeMap<K, V>

Returns:

this TreeMap if it is nonempty, otherwise TreeMap created from result of evaluating supplier, using existing comparator.
orElse
(Supplier<? extends Iterable<? extends Tuple2<K, V>>>
An alternative Traversable
supplier
)

Implements io.vavr.collection.SortedMap.orElse.

Returns this TreeMap if it is nonempty, otherwise TreeMap created from result of evaluating supplier, using existing comparator.

public Tuple2<TreeMap<K, V>, TreeMap<K, V>>
partition(Predicate<? super Tuple2<K, V>>
A predicate which classifies an element if it is in the first or the second traversable.
predicate
)

Implements io.vavr.collection.SortedMap.partition.

Creates a partition of this Traversable by splitting this elements in two in distinct traversables according to a predicate.

public TreeMap<K, V>
peek(Consumer<? super Tuple2<K, V>>
The action that will be performed on the element(s).
action
)

Implements io.vavr.collection.SortedMap.peek.

Performs the given action on the first element if this is an eager implementation.

public <U extends V> TreeMap<K, V>
put(K
key with which the specified value is to be associated
key
,
U
value to be associated with the specified key
value
,
BiFunction<? super V, ? super U, ? extends V>
function taking the old and new values and merging them.
merge
)

Implements io.vavr.collection.SortedMap.put.

Associates the specified value with the specified key in this map.

public TreeMap<K, V>
put(K
key with which the specified value is to be associated
key
,
V
value to be associated with the specified key
value
)

Implements io.vavr.collection.SortedMap.put.

Associates the specified value with the specified key in this map.

public TreeMap<K, V>
put(Tuple2<? extends K, ? extends V>
A Tuple2 containing the key and value
entry
)

Implements io.vavr.collection.SortedMap.put.

Convenience method for put(entry._1, entry._2).

public <U extends V> TreeMap<K, V>
put(Tuple2<? extends K, U>
A Tuple2 containing the key and value
entry
,
BiFunction<? super V, ? super U, ? extends V>
function taking the old and new values and merging them.
merge
)

Implements io.vavr.collection.SortedMap.put, io.vavr.collection.SortedMap.put.

Convenience method for put(entry._1, entry._2, merge).

public TreeMap<K, V>
reject(BiPredicate<? super K, ? super V>
the predicate used to test elements
predicate
)

Implements io.vavr.collection.SortedMap.reject.

Returns a new Map consisting of all elements which do not satisfy the given predicate.

public TreeMap<K, V>
reject(Predicate<? super Tuple2<K, V>>
A predicate
predicate
)

Implements io.vavr.collection.SortedMap.reject.

Returns a new traversable consisting of all elements which do not satisfy the given predicate.

public TreeMap<K, V>
rejectKeys(Predicate<? super K>
the predicate used to test keys of elements
predicate
)

Implements io.vavr.collection.SortedMap.rejectKeys.

Returns a new Map consisting of all elements with keys which do not satisfy the given predicate.

public TreeMap<K, V>
rejectValues(Predicate<? super V>
the predicate used to test values of elements
predicate
)

Implements io.vavr.collection.SortedMap.rejectValues.

Returns a new Map consisting of all elements with values which do not satisfy the given predicate.

public TreeMap<K, V>
remove(K
key whose mapping is to be removed from the map
key
)

Implements io.vavr.collection.SortedMap.remove.

Removes the mapping for a key from this map if it is present.

public TreeMap<K, V>
removeAll(BiPredicate<? super K, ? super V>
the predicate used to test elements
predicate
)

Implements io.vavr.collection.SortedMap.removeAll.

Deprecated

Returns a new Map consisting of all elements which do not satisfy the given predicate.

public TreeMap<K, V>
removeAll(Iterable<? extends K>
keys are to be removed from the map
keys
)

Implements io.vavr.collection.SortedMap.removeAll.

Removes the mapping for a key from this map if it is present.

public TreeMap<K, V>
removeKeys(Predicate<? super K>
the predicate used to test keys of elements
predicate
)

Implements io.vavr.collection.SortedMap.removeKeys.

Deprecated

Returns a new Map consisting of all elements with keys which do not satisfy the given predicate.

public TreeMap<K, V>
removeValues(Predicate<? super V>
the predicate used to test values of elements
predicate
)

Implements io.vavr.collection.SortedMap.removeValues.

Deprecated

Returns a new Map consisting of all elements with values which do not satisfy the given predicate.

public TreeMap<K, V>
replace(Tuple2<K, V>
An element to be substituted.
currentElement
,
Tuple2<K, V>
A replacement for currentElement.
newElement
)

Implements io.vavr.collection.SortedMap.replace.

Replaces the first occurrence (if exists) of the given currentElement with newElement.

public TreeMap<K, V>
replace(K
the key of the element to be substituted.
key
,
V
the expected current value that the key is currently mapped to
oldValue
,
V
the new value to be associated with the key
newValue
)

Implements io.vavr.collection.SortedMap.replace.

Replaces the entry for the specified key only if currently mapped to the specified value.

public TreeMap<K, V>
replaceAll(Tuple2<K, V>
An element to be substituted.
currentElement
,
Tuple2<K, V>
A replacement for currentElement.
newElement
)

Implements io.vavr.collection.SortedMap.replaceAll.

Replaces all occurrences of the given currentElement with newElement.

public TreeMap<K, V>
replaceAll(BiFunction<? super K, ? super V, ? extends V>
function transforming key and current value to a new value
function
)

Implements io.vavr.collection.SortedMap.replaceAll.

Replaces each entry's value with the result of invoking the given function on that entry until all entries have been processed or the function throws an exception.

public TreeMap<K, V>
replaceValue(K
the key of the element to be substituted.
key
,
V
the new value to be associated with the key
value
)

Implements io.vavr.collection.SortedMap.replaceValue.

Replaces the entry for the specified key only if it is currently mapped to some value.

public TreeMap<K, V>
retainAll(Iterable<? extends Tuple2<K, V>>
Elements to be kept.
elements
)

Implements io.vavr.collection.SortedMap.retainAll.

Keeps all occurrences of the given elements from this.

public TreeMap<K, V>
scan(Tuple2<K, V>
neutral element for the operator op
zero
,
BiFunction<? super Tuple2<K, V>, ? super Tuple2<K, V>, ? extends Tuple2<K, V>>
the associative operator for the scan
operation
)

Implements io.vavr.collection.SortedMap.scan.

Computes a prefix scan of the elements of the collection.

public int
size()

Implements io.vavr.collection.Map.size.

Computes the number of elements of this Traversable.

public Iterator<TreeMap<K, V>>
slideBy(Function<? super Tuple2<K, V>, ?>
A function which classifies elements into classes
classifier
)

Implements io.vavr.collection.SortedMap.slideBy.

Slides a non-overlapping window of a variable size over this Traversable.

public Iterator<TreeMap<K, V>>
sliding(int
a positive window size
size
)

Implements io.vavr.collection.SortedMap.sliding.

Slides a window of a specific size and step size 1 over this Traversable by calling sliding(int, int).

public Iterator<TreeMap<K, V>>
sliding(int
a positive window size
size
,
int
a positive step size
step
)

Implements io.vavr.collection.SortedMap.sliding.

Slides a window of a specific size and step size over this Traversable.

public Tuple2<TreeMap<K, V>, TreeMap<K, V>>
span(Predicate<? super Tuple2<K, V>>
A predicate.
predicate
)

Implements io.vavr.collection.SortedMap.span.

Returns a tuple where the first element is the longest prefix of elements that satisfy the given predicate and the second element is the remainder.

public String
stringPrefix()

Implements io.vavr.Value.stringPrefix.

Returns the name of this Value type, which is used by toString().

public static <
The key type
K
,
The value type
V
>
TreeMap<K, V>

Returns:

A TreeMap consisting of elements f(0),f(1), ..., f(n - 1)
tabulate
(Comparator<? super K>
The comparator used to sort the entries by their key
keyComparator
,
int
The number of elements in the TreeMap
n
,
Function<? super Integer, ? extends Tuple2<? extends K, ? extends V>>
The Function computing element values
f
)

Returns a TreeMap containing n values of a given Function f over a range of integer values from 0 to n - 1.

public static <
The key type
K extends Comparable<? super K>
,
The value type
V
>
TreeMap<K, V>

Returns:

A TreeMap consisting of elements f(0),f(1), ..., f(n - 1)
tabulate
(int
The number of elements in the TreeMap
n
,
Function<? super Integer, ? extends Tuple2<? extends K, ? extends V>>
The Function computing element values
f
)

Returns a TreeMap containing n values of a given Function f over a range of integer values from 0 to n - 1.

public TreeMap<K, V>
tail()

Implements io.vavr.collection.SortedMap.tail.

Drops the first element of a non-empty Traversable.

public Option<TreeMap<K, V>>
tailOption()

Implements io.vavr.collection.SortedMap.tailOption.

Drops the first element of a non-empty Traversable and returns an Option.

public TreeMap<K, V>
take(int
The number of elements to take.
n
)

Implements io.vavr.collection.SortedMap.take.

Takes the first n elements of this or all elements, if this length < n.

public TreeMap<K, V>
takeRight(int
The number of elements to take.
n
)

Implements io.vavr.collection.SortedMap.takeRight.

Takes the last n elements of this or all elements, if this length < n.

public TreeMap<K, V>
takeUntil(Predicate<? super Tuple2<K, V>>
A condition tested subsequently for this elements.
predicate
)

Implements io.vavr.collection.SortedMap.takeUntil.

Takes elements until the predicate holds for the current element.

public TreeMap<K, V>
takeWhile(Predicate<? super Tuple2<K, V>>
A condition tested subsequently for the contained elements.
predicate
)

Implements io.vavr.collection.SortedMap.takeWhile.

Takes elements while the predicate holds for the current element.

public TreeMap<K, V>
toJavaMap()

Implements io.vavr.collection.SortedMap.toJavaMap.

Converts this Vavr Map to a java.util.Map while preserving characteristics like insertion order (LinkedHashMap) and sort order (SortedMap).

public String
toString()

Overrides java.lang.Object.toString.

Implements io.vavr.Value.toString.

Clarifies that values have a proper toString() method implemented.

public Seq<V>
values()

Implements io.vavr.collection.Map.values.

Returns a new Seq that contains the values of this Map.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait