K
- Key typeV
- Value typepublic interface SortedMultimap<K,V> extends Multimap<K,V>, Ordered<K>
SortedMultimap
interface.Multimap.ContainerType
Modifier and Type | Field and Description |
---|---|
static long |
serialVersionUID |
Modifier and Type | Method and Description |
---|---|
SortedMultimap<K,V> |
distinct()
Returns a new version of this which contains no duplicates.
|
SortedMultimap<K,V> |
distinctBy(Comparator<? super Tuple2<K,V>> comparator)
Returns a new version of this which contains no duplicates.
|
<U> SortedMultimap<K,V> |
distinctBy(Function<? super Tuple2<K,V>,? extends U> keyExtractor)
Returns a new version of this which contains no duplicates.
|
SortedMultimap<K,V> |
drop(int n)
Drops the first n elements of this or all elements, if this length < n.
|
SortedMultimap<K,V> |
dropRight(int n)
Drops the last n elements of this or all elements, if this length < n.
|
SortedMultimap<K,V> |
dropUntil(Predicate<? super Tuple2<K,V>> predicate)
Drops elements until the predicate holds for the current element.
|
SortedMultimap<K,V> |
dropWhile(Predicate<? super Tuple2<K,V>> predicate)
Drops elements while the predicate holds for the current element.
|
SortedMultimap<K,V> |
filter(BiPredicate<? super K,? super V> predicate)
Returns a new Multimap consisting of all elements which satisfy the given predicate.
|
SortedMultimap<K,V> |
filter(Predicate<? super Tuple2<K,V>> predicate)
Returns a new traversable consisting of all elements which satisfy the given predicate.
|
SortedMultimap<K,V> |
filterKeys(Predicate<? super K> predicate)
Returns a new Multimap consisting of all elements with keys which satisfy the given predicate.
|
SortedMultimap<K,V> |
filterValues(Predicate<? super V> predicate)
Returns a new Multimap consisting of all elements with values which satisfy the given predicate.
|
<C> Map<C,? extends SortedMultimap<K,V>> |
groupBy(Function<? super Tuple2<K,V>,? extends C> classifier)
Groups this elements by classifying the elements.
|
Iterator<? extends SortedMultimap<K,V>> |
grouped(int size)
Groups this
Traversable into fixed size blocks. |
SortedMultimap<K,V> |
init()
Dual of Traversable.tail(), returning all elements except the last.
|
Option<? extends SortedMultimap<K,V>> |
initOption()
Dual of Traversable.tailOption(), returning all elements except the last as
Option . |
SortedSet<K> |
keySet()
Returns the keys contained in this multimap.
|
SortedMultimap<K,V> |
merge(Multimap<? extends K,? extends V> that)
Creates a new multimap which by merging the entries of
this multimap and that multimap. |
<K2 extends K,V2 extends V> |
merge(Multimap<K2,V2> that,
BiFunction<Traversable<V>,Traversable<V2>,Traversable<V>> collisionResolution)
Creates a new multimap which by merging the entries of
this multimap and that multimap. |
static <K,V> SortedMultimap<K,V> |
narrow(SortedMultimap<? extends K,? extends V> map)
Narrows a widened
SortedMultimap<? extends K, ? extends V> to SortedMultimap<K, V>
by performing a type-safe cast. |
SortedMultimap<K,V> |
orElse(Iterable<? extends Tuple2<K,V>> other)
Returns this
Traversable if it is nonempty, otherwise return the alternative. |
SortedMultimap<K,V> |
orElse(Supplier<? extends Iterable<? extends Tuple2<K,V>>> supplier)
Returns this
Traversable if it is nonempty, otherwise return the result of evaluating supplier. |
Tuple2<? extends SortedMultimap<K,V>,? extends SortedMultimap<K,V>> |
partition(Predicate<? super Tuple2<K,V>> predicate)
Creates a partition of this
Traversable by splitting this elements in two in distinct traversables
according to a predicate. |
SortedMultimap<K,V> |
peek(Consumer<? super Tuple2<K,V>> action)
Performs the given
action on the first element if this is an eager implementation. |
SortedMultimap<K,V> |
put(K key,
V value)
Associates the specified value with the specified key in this multimap.
|
SortedMultimap<K,V> |
put(Tuple2<? extends K,? extends V> entry)
Convenience method for
put(entry._1, entry._2) . |
SortedMultimap<K,V> |
reject(BiPredicate<? super K,? super V> predicate)
Returns a new Multimap consisting of all elements which do not satisfy the given predicate.
|
SortedMultimap<K,V> |
reject(Predicate<? super Tuple2<K,V>> predicate)
Returns a new traversable consisting of all elements which do not satisfy the given predicate.
|
SortedMultimap<K,V> |
rejectKeys(Predicate<? super K> predicate)
Returns a new Multimap consisting of all elements with keys which do not satisfy the given predicate.
|
SortedMultimap<K,V> |
rejectValues(Predicate<? super V> predicate)
Returns a new Multimap consisting of all elements with values which do not satisfy the given predicate.
|
SortedMultimap<K,V> |
remove(K key)
Removes the mapping for a key from this multimap if it is present.
|
SortedMultimap<K,V> |
remove(K key,
V value)
Removes the key-value pair from this multimap if it is present.
|
SortedMultimap<K,V> |
removeAll(BiPredicate<? super K,? super V> predicate)
Deprecated.
|
SortedMultimap<K,V> |
removeAll(Iterable<? extends K> keys)
Removes the mapping for a key from this multimap if it is present.
|
SortedMultimap<K,V> |
removeKeys(Predicate<? super K> predicate)
Deprecated.
|
SortedMultimap<K,V> |
removeValues(Predicate<? super V> predicate)
Deprecated.
|
SortedMultimap<K,V> |
replace(K key,
V oldValue,
V newValue)
Replaces the entry with the specified key and oldValue.
|
SortedMultimap<K,V> |
replace(Tuple2<K,V> currentElement,
Tuple2<K,V> newElement)
Replaces the first occurrence (if exists) of the given currentElement with newElement.
|
SortedMultimap<K,V> |
replaceAll(BiFunction<? super K,? super V,? extends V> function)
Replaces each entry's values with the result of invoking the given function on that each tuple until all entries have been processed or the function throws an exception.
|
SortedMultimap<K,V> |
replaceAll(Tuple2<K,V> currentElement,
Tuple2<K,V> newElement)
Replaces all occurrences of the given currentElement with newElement.
|
SortedMultimap<K,V> |
replaceValue(K key,
V value)
Replaces the entry for the specified key only if it is currently mapped to some value.
|
SortedMultimap<K,V> |
retainAll(Iterable<? extends Tuple2<K,V>> elements)
Keeps all occurrences of the given elements from this.
|
SortedMultimap<K,V> |
scan(Tuple2<K,V> zero,
BiFunction<? super Tuple2<K,V>,? super Tuple2<K,V>,? extends Tuple2<K,V>> operation)
Computes a prefix scan of the elements of the collection.
|
Iterator<? extends SortedMultimap<K,V>> |
slideBy(Function<? super Tuple2<K,V>,?> classifier)
Slides a non-overlapping window of a variable size over this
Traversable . |
Iterator<? extends SortedMultimap<K,V>> |
sliding(int size)
Slides a window of a specific
size and step size 1 over this Traversable by calling
Traversable.sliding(int, int) . |
Iterator<? extends SortedMultimap<K,V>> |
sliding(int size,
int step)
Slides a window of a specific
size and step size over this Traversable . |
Tuple2<? extends SortedMultimap<K,V>,? extends SortedMultimap<K,V>> |
span(Predicate<? super Tuple2<K,V>> predicate)
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. |
SortedMultimap<K,V> |
tail()
Drops the first element of a non-empty Traversable.
|
Option<? extends SortedMultimap<K,V>> |
tailOption()
Drops the first element of a non-empty Traversable and returns an
Option . |
SortedMultimap<K,V> |
take(int n)
Takes the first n elements of this or all elements, if this length < n.
|
SortedMultimap<K,V> |
takeRight(int n)
Takes the last n elements of this or all elements, if this length < n.
|
SortedMultimap<K,V> |
takeUntil(Predicate<? super Tuple2<K,V>> predicate)
Takes elements until the predicate holds for the current element.
|
SortedMultimap<K,V> |
takeWhile(Predicate<? super Tuple2<K,V>> predicate)
Takes elements while the predicate holds for the current element.
|
SortedMap<K,Collection<V>> |
toJavaMap()
Converts this Vavr
Map to a java.util.Map while preserving characteristics
like insertion order (LinkedHashMultimap ) and sort order (SortedMultimap ). |
apply, asMap, asPartialFunction, bimap, collect, contains, containsKey, containsValue, flatMap, flatMap, foldRight, forEach, get, getContainerType, getOrElse, hasDefiniteSize, isDefinedAt, isDistinct, isTraversableAgain, iterator, iterator, length, map, map, mapValues, narrow, scanLeft, scanRight, size, transform, unzip, unzip, unzip3, unzip3, values, zip, zipAll, zipWith, zipWithIndex, zipWithIndex
arrangeBy, average, containsAll, count, equals, existsUnique, find, findLast, foldLeft, forEachWithIndex, get, hashCode, head, headOption, isEmpty, isOrdered, isSequential, isSingleValued, last, lastOption, max, maxBy, maxBy, min, minBy, minBy, mkCharSeq, mkCharSeq, mkCharSeq, mkString, mkString, mkString, narrow, nonEmpty, product, reduceLeft, reduceLeftOption, reduceRight, reduceRightOption, single, singleOption, spliterator, sum
fold, reduce, reduceOption
collect, collect, corresponds, eq, exists, forAll, forEach, getOrElse, getOrElse, getOrElseThrow, getOrElseTry, getOrNull, isAsync, isLazy, narrow, out, out, stderr, stdout, stringPrefix, toArray, toCharSeq, toCompletableFuture, toEither, toEither, toInvalid, toInvalid, toJavaArray, toJavaArray, toJavaArray, toJavaCollection, toJavaList, toJavaList, toJavaMap, toJavaMap, toJavaMap, toJavaOptional, toJavaParallelStream, toJavaSet, toJavaSet, toJavaStream, toLeft, toLeft, toLinkedMap, toLinkedMap, toLinkedSet, toList, toMap, toMap, toOption, toPriorityQueue, toPriorityQueue, toQueue, toRight, toRight, toSet, toSortedMap, toSortedMap, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toStream, toString, toTree, toTree, toTry, toTry, toValid, toValid, toValidation, toValidation, toVector
getIfDefined, lift, unlift
andThen, arity, compose, constant, curried, identity, isMemoized, lift, liftTry, memoized, narrow, of, partial, reversed, tupled
comparator
static final long serialVersionUID
static <K,V> SortedMultimap<K,V> narrow(SortedMultimap<? extends K,? extends V> map)
SortedMultimap<? extends K, ? extends V>
to SortedMultimap<K, V>
by performing a type-safe cast. This is eligible because immutable/read-only
collections are covariant.K
- Key typeV
- Value typemap
- A SortedMultimap
.multimap
instance as narrowed type SortedMultimap<K, V>
.SortedMultimap<K,V> filter(BiPredicate<? super K,? super V> predicate)
Multimap
SortedMultimap<K,V> reject(BiPredicate<? super K,? super V> predicate)
Multimap
SortedMultimap<K,V> filterKeys(Predicate<? super K> predicate)
Multimap
filterKeys
in interface Multimap<K,V>
predicate
- the predicate used to test keys of elementsSortedMultimap<K,V> rejectKeys(Predicate<? super K> predicate)
Multimap
rejectKeys
in interface Multimap<K,V>
predicate
- the predicate used to test keys of elementsSortedMultimap<K,V> filterValues(Predicate<? super V> predicate)
Multimap
filterValues
in interface Multimap<K,V>
predicate
- the predicate used to test values of elementsSortedMultimap<K,V> rejectValues(Predicate<? super V> predicate)
Multimap
rejectValues
in interface Multimap<K,V>
predicate
- the predicate used to test values of elementsSortedSet<K> keySet()
Multimap
SortedMultimap<K,V> merge(Multimap<? extends K,? extends V> that)
Multimap
this
multimap and that
multimap.
If collisions occur, the value of this
multimap is taken.
<K2 extends K,V2 extends V> SortedMultimap<K,V> merge(Multimap<K2,V2> that, BiFunction<Traversable<V>,Traversable<V2>,Traversable<V>> collisionResolution)
Multimap
this
multimap and that
multimap.
Uses the specified collision resolution function if two keys are the same.
The collision resolution function will always take the first argument from this
multimap
and the second from that
multimap.
SortedMultimap<K,V> put(K key, V value)
Multimap
SortedMultimap<K,V> put(Tuple2<? extends K,? extends V> entry)
Multimap
put(entry._1, entry._2)
.SortedMultimap<K,V> remove(K key)
Multimap
SortedMultimap<K,V> remove(K key, V value)
Multimap
@Deprecated SortedMultimap<K,V> removeAll(BiPredicate<? super K,? super V> predicate)
Multimap
SortedMultimap<K,V> removeAll(Iterable<? extends K> keys)
Multimap
@Deprecated SortedMultimap<K,V> removeKeys(Predicate<? super K> predicate)
Multimap
removeKeys
in interface Multimap<K,V>
predicate
- the predicate used to test keys of elements@Deprecated SortedMultimap<K,V> removeValues(Predicate<? super V> predicate)
Multimap
removeValues
in interface Multimap<K,V>
predicate
- the predicate used to test values of elementsSortedMap<K,Collection<V>> toJavaMap()
Multimap
Map
to a java.util.Map
while preserving characteristics
like insertion order (LinkedHashMultimap
) and sort order (SortedMultimap
).SortedMultimap<K,V> distinct()
Traversable
equals
.SortedMultimap<K,V> distinctBy(Comparator<? super Tuple2<K,V>> comparator)
Traversable
comparator
.distinctBy
in interface Multimap<K,V>
distinctBy
in interface Traversable<Tuple2<K,V>>
comparator
- A comparatorTraversable
containing this elements without duplicates<U> SortedMultimap<K,V> distinctBy(Function<? super Tuple2<K,V>,? extends U> keyExtractor)
Traversable
equals
.
The elements of the result are determined in the order of their occurrence - first match wins.
distinctBy
in interface Multimap<K,V>
distinctBy
in interface Traversable<Tuple2<K,V>>
U
- key typekeyExtractor
- A key extractorTraversable
containing this elements without duplicatesSortedMultimap<K,V> drop(int n)
Traversable
SortedMultimap<K,V> dropRight(int n)
Traversable
dropRight
in interface Multimap<K,V>
dropRight
in interface Traversable<Tuple2<K,V>>
n
- The number of elements to drop.SortedMultimap<K,V> dropUntil(Predicate<? super Tuple2<K,V>> predicate)
Traversable
dropUntil
in interface Multimap<K,V>
dropUntil
in interface Traversable<Tuple2<K,V>>
predicate
- A condition tested subsequently for this elements.SortedMultimap<K,V> dropWhile(Predicate<? super Tuple2<K,V>> predicate)
Traversable
Note: This is essentially the same as dropUntil(predicate.negate())
.
It is intended to be used with method references, which cannot be negated directly.
dropWhile
in interface Multimap<K,V>
dropWhile
in interface Traversable<Tuple2<K,V>>
predicate
- A condition tested subsequently for this elements.SortedMultimap<K,V> filter(Predicate<? super Tuple2<K,V>> predicate)
Traversable
SortedMultimap<K,V> reject(Predicate<? super Tuple2<K,V>> predicate)
Traversable
The default implementation is equivalent to
filter(predicate.negate()
<C> Map<C,? extends SortedMultimap<K,V>> groupBy(Function<? super Tuple2<K,V>,? extends C> classifier)
Traversable
groupBy
in interface Multimap<K,V>
groupBy
in interface Traversable<Tuple2<K,V>>
C
- classified class typeclassifier
- A function which classifies elements into classesTraversable.arrangeBy(Function)
Iterator<? extends SortedMultimap<K,V>> grouped(int size)
Traversable
Traversable
into fixed size blocks.
Let length be the length of this Iterable. Then grouped is defined as follows:
this.isEmpty()
, the resulting Iterator
is empty.size <= length
, the resulting Iterator
will contain length / size
blocks of size
size
and maybe a non-empty block of size length % size
, if there are remaining elements.size > length
, the resulting Iterator
will contain one block of size length
.
[].grouped(1) = []
[].grouped(0) throws
[].grouped(-1) throws
[1,2,3,4].grouped(2) = [[1,2],[3,4]]
[1,2,3,4,5].grouped(2) = [[1,2],[3,4],[5]]
[1,2,3,4].grouped(5) = [[1,2,3,4]]
Please note that grouped(int)
is a special case of Traversable.sliding(int, int), i.e.
grouped(size)
is the same as sliding(size, size)
.SortedMultimap<K,V> init()
Traversable
Option<? extends SortedMultimap<K,V>> initOption()
Traversable
Option
.initOption
in interface Multimap<K,V>
initOption
in interface Traversable<Tuple2<K,V>>
Some(traversable)
or None
if this is empty.SortedMultimap<K,V> orElse(Iterable<? extends Tuple2<K,V>> other)
Traversable
Traversable
if it is nonempty, otherwise return the alternative.SortedMultimap<K,V> orElse(Supplier<? extends Iterable<? extends Tuple2<K,V>>> supplier)
Traversable
Traversable
if it is nonempty, otherwise return the result of evaluating supplier.Tuple2<? extends SortedMultimap<K,V>,? extends SortedMultimap<K,V>> partition(Predicate<? super Tuple2<K,V>> predicate)
Traversable
Traversable
by splitting this elements in two in distinct traversables
according to a predicate.partition
in interface Multimap<K,V>
partition
in interface Traversable<Tuple2<K,V>>
predicate
- A predicate which classifies an element if it is in the first or the second traversable.Traversable
contains all elements that satisfy the given predicate
, the second Traversable
contains all elements that don't. The original order of elements is preserved.SortedMultimap<K,V> peek(Consumer<? super Tuple2<K,V>> action)
Value
action
on the first element if this is an eager implementation.
Performs the given action
on all elements (the first immediately, successive deferred),
if this is a lazy implementation.SortedMultimap<K,V> replace(Tuple2<K,V> currentElement, Tuple2<K,V> newElement)
Traversable
replace
in interface Multimap<K,V>
replace
in interface Traversable<Tuple2<K,V>>
currentElement
- An element to be substituted.newElement
- A replacement for currentElement.SortedMultimap<K,V> replaceAll(Tuple2<K,V> currentElement, Tuple2<K,V> newElement)
Traversable
replaceAll
in interface Multimap<K,V>
replaceAll
in interface Traversable<Tuple2<K,V>>
currentElement
- An element to be substituted.newElement
- A replacement for currentElement.SortedMultimap<K,V> replaceValue(K key, V value)
Multimap
replaceValue
in interface Multimap<K,V>
key
- the key of the element to be substitutedvalue
- the new value to be associated with the keySortedMultimap<K,V> replace(K key, V oldValue, V newValue)
Multimap
replace
in interface Multimap<K,V>
key
- the key of the element to be substitutedoldValue
- the expected current value associated with the keynewValue
- the new value to be associated with the keySortedMultimap<K,V> replaceAll(BiFunction<? super K,? super V,? extends V> function)
Multimap
replaceAll
in interface Multimap<K,V>
function
- function transforming key and current value to a new valueSortedMultimap<K,V> retainAll(Iterable<? extends Tuple2<K,V>> elements)
Traversable
SortedMultimap<K,V> scan(Tuple2<K,V> zero, BiFunction<? super Tuple2<K,V>,? super Tuple2<K,V>,? extends Tuple2<K,V>> operation)
Traversable
scan
in interface Multimap<K,V>
scan
in interface Traversable<Tuple2<K,V>>
zero
- neutral element for the operator opoperation
- the associative operator for the scanIterator<? extends SortedMultimap<K,V>> slideBy(Function<? super Tuple2<K,V>,?> classifier)
Traversable
Traversable
.
Each window contains elements with the same class, as determined by classifier
. Two consecutive
values in this Traversable
will be in the same window only if classifier
returns equal
values for them. Otherwise, the values will constitute the last element of the previous window and the
first element of the next window.
Examples:
[].slideBy(Function.identity()) = []
[1,2,3,4,4,5].slideBy(Function.identity()) = [[1],[2],[3],[4,4],[5]]
[1,2,3,10,12,5,7,20,29].slideBy(x -> x/10) = [[1,2,3],[10,12],[5,7],[20,29]]
Iterator<? extends SortedMultimap<K,V>> sliding(int size)
Traversable
size
and step size 1 over this Traversable
by calling
Traversable.sliding(int, int)
.Iterator<? extends SortedMultimap<K,V>> sliding(int size, int step)
Traversable
size
and step
size over this Traversable
.
Examples:
[].sliding(1,1) = []
[1,2,3,4,5].sliding(2,3) = [[1,2],[4,5]]
[1,2,3,4,5].sliding(2,4) = [[1,2],[5]]
[1,2,3,4,5].sliding(2,5) = [[1,2]]
[1,2,3,4].sliding(5,3) = [[1,2,3,4],[4]]
Tuple2<? extends SortedMultimap<K,V>,? extends SortedMultimap<K,V>> span(Predicate<? super Tuple2<K,V>> predicate)
Traversable
predicate
and the second element is the remainder.SortedMultimap<K,V> tail()
Traversable
Option<? extends SortedMultimap<K,V>> tailOption()
Traversable
Option
.tailOption
in interface Multimap<K,V>
tailOption
in interface Traversable<Tuple2<K,V>>
Some(traversable)
or None
if this is empty.SortedMultimap<K,V> take(int n)
Traversable
The result is equivalent to sublist(0, max(0, min(length(), n)))
but does not throw if n < 0
or
n > length()
.
In the case of n < 0
the empty instance is returned, in the case of n > length()
this is returned.
SortedMultimap<K,V> takeRight(int n)
Traversable
The result is equivalent to sublist(max(0, min(length(), length() - n)), n)
, i.e. takeRight will not
throw if n < 0
or n > length()
.
In the case of n < 0
the empty instance is returned, in the case of n > length()
this is returned.
SortedMultimap<K,V> takeUntil(Predicate<? super Tuple2<K,V>> predicate)
Traversable
Note: This is essentially the same as takeWhile(predicate.negate())
. It is intended to be used with
method references, which cannot be negated directly.
SortedMultimap<K,V> takeWhile(Predicate<? super Tuple2<K,V>> predicate)
Traversable
takeWhile
in interface Multimap<K,V>
takeWhile
in interface Traversable<Tuple2<K,V>>
predicate
- A condition tested subsequently for the contained elements.Copyright © 2019. All Rights Reserved.