Top Description Fields Methods
io.vavr.collection

public Interface SortedMap<K, V>

extends Map<K, V>, Ordered<K>
Known Direct Implementers
io.vavr.collection.TreeMap
Type Parameters
<K>
Key type
<V>
Value type
Imports
io.vavr.Tuple2, io.vavr.control.Option, java.util.Comparator, .NoSuchElementException, java.util.function.*

An immutable SortedMap interface.
Author
Daniel Dietrich

Field Summary

Modifier and TypeField and Description
public static final long

Method Summary

Modifier and TypeMethod and Description
public <
key's component type of the map result
K2
,
value's component type of the map result
V2
>
SortedMap<K2, V2>

Returns:

a new SortedMap
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
)

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

public <K2, V2> SortedMap<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
)

Redeclares io.vavr.collection.Map.bimap.

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

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

Redeclares io.vavr.collection.Map.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>, ? extends SortedMap<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
)

Redeclares io.vavr.collection.Map.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 SortedMap<K, V>
distinct()

Redeclares io.vavr.collection.Map.distinct.

Returns a new version of this which contains no duplicates.

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

Redeclares io.vavr.collection.Map.distinctBy.

Returns a new version of this which contains no duplicates.

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

Redeclares io.vavr.collection.Map.distinctBy.

Returns a new version of this which contains no duplicates.

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

Redeclares io.vavr.collection.Map.drop.

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

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

Redeclares io.vavr.collection.Map.dropRight.

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

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

Redeclares io.vavr.collection.Map.dropUntil.

Drops elements until the predicate holds for the current element.

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

Redeclares io.vavr.collection.Map.dropWhile.

Drops elements while the predicate holds for the current element.

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

Redeclares io.vavr.collection.Map.filter.

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

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

Redeclares io.vavr.collection.Map.filter.

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

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

Redeclares io.vavr.collection.Map.filterKeys.

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

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

Redeclares io.vavr.collection.Map.filterValues.

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

public <
New key type
K2
,
New value type
V2
>
SortedMap<K2, V2>

Returns:

A new Map instance containing mapped entries
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
)

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

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

Redeclares io.vavr.collection.Map.flatMap.

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

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

Redeclares io.vavr.collection.Map.groupBy.

Groups this elements by classifying the elements.

public Iterator<? extends SortedMap<K, V>>
grouped(int
a positive block size
size
)

Redeclares io.vavr.collection.Map.grouped.

Groups this Traversable into fixed size blocks.

public SortedMap<K, V>
init()

Redeclares io.vavr.collection.Map.init.

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

public Option<? extends SortedMap<K, V>>
initOption()

Redeclares io.vavr.collection.Map.initOption.

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

public default boolean
isOrdered()

Overrides default io.vavr.collection.Traversable.isOrdered.

Checks if this Traversable is ordered

public SortedSet<K>
keySet()

Redeclares io.vavr.collection.Map.keySet.

Returns the keys contained in this map.

public default Tuple2<K, V>
last()

Implements io.vavr.collection.Traversable.last.

Dual of head(), returning the last element.

public <
key's component type of the map result
K2
,
value's component type of the map result
V2
>
SortedMap<K2, V2>

Returns:

a new SortedMap
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
)

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

public <K2, V2> SortedMap<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
)

Redeclares io.vavr.collection.Map.map.

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

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

Redeclares io.vavr.collection.Map.mapKeys.

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

public <K2> SortedMap<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
)

Redeclares io.vavr.collection.Map.mapKeys.

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

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

Redeclares io.vavr.collection.Map.mapValues.

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

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

Redeclares io.vavr.collection.Map.merge.

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

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

Redeclares io.vavr.collection.Map.merge.

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

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

Returns:

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

Narrows a widened SortedMap<?

public SortedMap<K, V>
orElse(Iterable<? extends Tuple2<K, V>>
An alternative Traversable
other
)

Redeclares io.vavr.collection.Map.orElse.

Returns this Traversable if it is nonempty, otherwise return the alternative.

public SortedMap<K, V>
orElse(Supplier<? extends Iterable<? extends Tuple2<K, V>>>
An alternative Traversable supplier
supplier
)

Redeclares io.vavr.collection.Map.orElse.

Returns this Traversable if it is nonempty, otherwise return the result of evaluating supplier.

public Tuple2<? extends SortedMap<K, V>, ? extends SortedMap<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
)

Redeclares io.vavr.collection.Map.partition.

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

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

Redeclares io.vavr.collection.Map.peek.

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

public SortedMap<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
)

Redeclares io.vavr.collection.Map.put.

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

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

Redeclares io.vavr.collection.Map.put.

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

public <U extends V> SortedMap<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
)

Redeclares io.vavr.collection.Map.put.

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

public <U extends V> SortedMap<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
)

Redeclares io.vavr.collection.Map.put, io.vavr.collection.Map.put.

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

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

Redeclares io.vavr.collection.Map.reject.

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

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

Redeclares io.vavr.collection.Map.reject.

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

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

Redeclares io.vavr.collection.Map.rejectKeys.

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

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

Redeclares io.vavr.collection.Map.rejectValues.

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

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

Redeclares io.vavr.collection.Map.remove.

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

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

Redeclares io.vavr.collection.Map.removeAll.

Deprecated

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

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

Redeclares io.vavr.collection.Map.removeAll.

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

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

Redeclares io.vavr.collection.Map.removeKeys.

Deprecated

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

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

Redeclares io.vavr.collection.Map.removeValues.

Deprecated

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

public SortedMap<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
)

Redeclares io.vavr.collection.Map.replace.

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

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

Redeclares io.vavr.collection.Map.replace.

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

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

Redeclares io.vavr.collection.Map.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 SortedMap<K, V>
replaceAll(Tuple2<K, V>
An element to be substituted.
currentElement
,
Tuple2<K, V>
A replacement for currentElement.
newElement
)

Redeclares io.vavr.collection.Map.replaceAll.

Replaces all occurrences of the given currentElement with newElement.

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

Redeclares io.vavr.collection.Map.replaceValue.

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

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

Redeclares io.vavr.collection.Map.retainAll.

Keeps all occurrences of the given elements from this.

public SortedMap<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
)

Redeclares io.vavr.collection.Map.scan.

Computes a prefix scan of the elements of the collection.

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

Redeclares io.vavr.collection.Map.slideBy.

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

public Iterator<? extends SortedMap<K, V>>
sliding(int
a positive window size
size
)

Redeclares io.vavr.collection.Map.sliding.

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

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

Redeclares io.vavr.collection.Map.sliding.

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

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

Redeclares io.vavr.collection.Map.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 SortedMap<K, V>
tail()

Redeclares io.vavr.collection.Map.tail.

Drops the first element of a non-empty Traversable.

public Option<? extends SortedMap<K, V>>
tailOption()

Redeclares io.vavr.collection.Map.tailOption.

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

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

Redeclares io.vavr.collection.Map.take.

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

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

Redeclares io.vavr.collection.Map.takeRight.

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

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

Redeclares io.vavr.collection.Map.takeUntil.

Takes elements until the predicate holds for the current element.

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

Redeclares io.vavr.collection.Map.takeWhile.

Takes elements while the predicate holds for the current element.

public SortedMap<K, V>
toJavaMap()

Redeclares io.vavr.collection.Map.toJavaMap.

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

Inherited from io.vavr.collection.Map:
applyasPartialFunctioncollectcontainscontainsKeycontainsValueentryflatMapfoldRightforEachgetgetOrElsehasDefiniteSizeisDefinedAtisDistinctisTraversableAgainiteratoriteratorkeysIteratorlengthliftmapnarrowscanLeftscanRightsizetransformunzipunzipunzipunzip3unzip3valuesvaluesIteratorwithDefaultwithDefaultValuezipzipAllzipWithzipWithIndexzipWithIndex
Inherited from io.vavr.collection.Ordered:
comparator