Interface SortedMultimap<K,V>
-
- Type Parameters:
K- Key typeV- Value type
- All Superinterfaces:
Foldable<Tuple2<K,V>>,java.util.function.Function<K,Traversable<V>>,Function1<K,Traversable<V>>,java.lang.Iterable<Tuple2<K,V>>,Multimap<K,V>,Ordered<K>,PartialFunction<K,Traversable<V>>,java.io.Serializable,Traversable<Tuple2<K,V>>,Value<Tuple2<K,V>>
- All Known Implementing Classes:
TreeMultimap
public interface SortedMultimap<K,V> extends Multimap<K,V>, Ordered<K>
An immutableSortedMultimapinterface.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.vavr.collection.Multimap
Multimap.ContainerType
-
-
Field Summary
Fields Modifier and Type Field Description static longserialVersionUIDThe serial version UID for serialization.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description SortedMultimap<K,V>distinct()Returns a newTraversablecontaining the elements of this instance with all duplicates removed.SortedMultimap<K,V>distinctBy(@NonNull java.util.Comparator<? super Tuple2<K,V>> comparator)Returns a newTraversablecontaining the elements of this instance without duplicates, as determined by the givencomparator.<U> SortedMultimap<K,V>distinctBy(@NonNull java.util.function.Function<? super Tuple2<K,V>,? extends U> keyExtractor)Returns a newTraversablecontaining the elements of this instance without duplicates, based on keys extracted from elements usingkeyExtractor.SortedMultimap<K,V>drop(int n)Returns a newTraversablewithout the firstnelements, or an empty instance if this contains fewer thannelements.SortedMultimap<K,V>dropRight(int n)Returns a newTraversablewithout the lastnelements, or an empty instance if this contains fewer thannelements.SortedMultimap<K,V>dropUntil(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)Returns a newTraversablestarting from the first element that satisfies the givenpredicate, dropping all preceding elements.SortedMultimap<K,V>dropWhile(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)Returns a newTraversablestarting from the first element that does not satisfy the givenpredicate, dropping all preceding elements.SortedMultimap<K,V>filter(@NonNull java.util.function.BiPredicate<? super K,? super V> predicate)Returns a new Multimap consisting of all elements which satisfy the given predicate.SortedMultimap<K,V>filter(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)Returns a new traversable containing only the elements that satisfy the given predicate.SortedMultimap<K,V>filterKeys(@NonNull java.util.function.Predicate<? super K> predicate)Returns a new Multimap consisting of all elements with keys which satisfy the given predicate.SortedMultimap<K,V>filterValues(@NonNull java.util.function.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(@NonNull java.util.function.Function<? super Tuple2<K,V>,? extends C> classifier)Groups elements of thisTraversablebased on a classifier function.Iterator<? extends SortedMultimap<K,V>>grouped(int size)Splits thisTraversableinto consecutive blocks of the given size.SortedMultimap<K,V>init()Returns all elements of this Traversable except the last one.Option<? extends SortedMultimap<K,V>>initOption()Returns all elements of this Traversable except the last one, wrapped in anOption.SortedSet<K>keySet()Returns the keys contained in this multimap.SortedMultimap<K,V>merge(@NonNull Multimap<? extends K,? extends V> that)Creates a new multimap which by merging the entries ofthismultimap andthatmultimap.<K2 extends K,V2 extends V>
SortedMultimap<K,V>merge(@NonNull Multimap<K2,V2> that, @NonNull java.util.function.BiFunction<Traversable<V>,Traversable<V2>,Traversable<V>> collisionResolution)Creates a new multimap which by merging the entries ofthismultimap andthatmultimap.static <K,V>
SortedMultimap<K,V>narrow(SortedMultimap<? extends K,? extends V> map)Narrows a widenedSortedMultimap<? extends K, ? extends V>toSortedMultimap<K, V>by performing a type-safe cast.SortedMultimap<K,V>orElse(@NonNull java.util.function.Supplier<? extends java.lang.Iterable<? extends Tuple2<K,V>>> supplier)Returns thisTraversableif it is non-empty; otherwise, returns the result of evaluating the given supplier.SortedMultimap<K,V>orElse(java.lang.Iterable<? extends Tuple2<K,V>> other)Returns thisTraversableif it is non-empty; otherwise, returns the given alternative.Tuple2<? extends SortedMultimap<K,V>,? extends SortedMultimap<K,V>>partition(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)Splits thisTraversableinto two partitions according to a predicate.SortedMultimap<K,V>peek(@NonNull java.util.function.Consumer<? super Tuple2<K,V>> action)Performs the givenactionon the first element if this is an eager implementation.SortedMultimap<K,V>put(@NonNull Tuple2<? extends K,? extends V> entry)Convenience method forput(entry._1, entry._2).SortedMultimap<K,V>put(K key, V value)Associates the specified value with the specified key in this multimap.SortedMultimap<K,V>reject(@NonNull java.util.function.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(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)Returns a new traversable containing only the elements that do not satisfy the given predicate.SortedMultimap<K,V>rejectKeys(@NonNull java.util.function.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(@NonNull java.util.function.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(@NonNull java.lang.Iterable<? extends K> keys)Removes the mapping for a key from this multimap if it is present.SortedMultimap<K,V>removeAll(@NonNull java.util.function.BiPredicate<? super K,? super V> predicate)Deprecated.SortedMultimap<K,V>removeKeys(@NonNull java.util.function.Predicate<? super K> predicate)Deprecated.SortedMultimap<K,V>removeValues(@NonNull java.util.function.Predicate<? super V> predicate)Deprecated.SortedMultimap<K,V>replace(@NonNull Tuple2<K,V> currentElement, Tuple2<K,V> newElement)Replaces the first occurrence ofcurrentElementwithnewElement, if it exists.SortedMultimap<K,V>replace(K key, V oldValue, V newValue)Replaces the entry with the specified key and oldValue.SortedMultimap<K,V>replaceAll(@NonNull Tuple2<K,V> currentElement, Tuple2<K,V> newElement)Replaces all occurrences ofcurrentElementwithnewElement.SortedMultimap<K,V>replaceAll(@NonNull java.util.function.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>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(@NonNull java.lang.Iterable<? extends Tuple2<K,V>> elements)Retains only the elements from this Traversable that are contained in the givenelements.SortedMultimap<K,V>scan(Tuple2<K,V> zero, @NonNull java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K,V>,? extends Tuple2<K,V>> operation)Computes a prefix scan of the elements of this Traversable.Iterator<? extends SortedMultimap<K,V>>slideBy(@NonNull java.util.function.Function<? super Tuple2<K,V>,?> classifier)Partitions thisTraversableinto consecutive non-overlapping windows according to a classification function.Iterator<? extends SortedMultimap<K,V>>sliding(int size)Slides a window of a givensizeover thisTraversablewith a step size of 1.Iterator<? extends SortedMultimap<K,V>>sliding(int size, int step)Slides a window of a specificsizewith a givenstepover thisTraversable.Tuple2<? extends SortedMultimap<K,V>,? extends SortedMultimap<K,V>>span(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)Splits thisTraversableinto a prefix and remainder according to the givenpredicate.SortedMultimap<K,V>tail()Returns a newTraversablewithout its first element.Option<? extends SortedMultimap<K,V>>tailOption()Returns a newTraversablewithout its first element as anOption.SortedMultimap<K,V>take(int n)Returns the firstnelements of thisTraversable, or all elements ifnexceeds the length.SortedMultimap<K,V>takeRight(int n)Returns the lastnelements of thisTraversable, or all elements ifnexceeds the length.SortedMultimap<K,V>takeUntil(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)Takes elements from thisTraversableuntil the given predicate holds for an element.SortedMultimap<K,V>takeWhile(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)Takes elements from thisTraversablewhile the given predicate holds.java.util.SortedMap<K,java.util.Collection<V>>toJavaMap()Converts this VavrMapto ajava.util.Mapwhile preserving characteristics like insertion order (LinkedHashMultimap) and sort order (SortedMultimap).-
Methods inherited from interface io.vavr.collection.Foldable
fold, reduce, reduceOption
-
Methods inherited from interface io.vavr.Function1
andThen, arity, compose, compose1, curried, isMemoized, memoized, partial, reversed, tupled
-
Methods inherited from interface io.vavr.collection.Multimap
apply, asMap, asPartialFunction, bimap, collect, contains, containsKey, containsValue, flatMap, flatMap, foldRight, forEach, get, getContainerType, getOrElse, hasDefiniteSize, isDefinedAt, isDistinct, isTraversableAgain, iterator, iterator, length, map, map, mapTo, mapToVoid, mapValues, scanLeft, scanRight, size, transform, unzip, unzip, unzip3, unzip3, values, zip, zipAll, zipWith, zipWithIndex, zipWithIndex
-
Methods inherited from interface io.vavr.collection.Ordered
comparator
-
Methods inherited from interface io.vavr.PartialFunction
lift
-
Methods inherited from interface io.vavr.collection.Traversable
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, nonEmpty, product, reduceLeft, reduceLeftOption, reduceRight, reduceRightOption, single, singleOption, spliterator, sum
-
Methods inherited from interface io.vavr.Value
collect, collect, corresponds, eq, exists, forAll, forEach, getOrElse, getOrElse, getOrElseThrow, getOrElseTry, getOrNull, isAsync, isLazy, 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
-
-
-
-
Field Detail
-
serialVersionUID
static final long serialVersionUID
The serial version UID for serialization.- See Also:
- Constant Field Values
-
-
Method Detail
-
narrow
static <K,V> SortedMultimap<K,V> narrow(SortedMultimap<? extends K,? extends V> map)
Narrows a widenedSortedMultimap<? extends K, ? extends V>toSortedMultimap<K, V>by performing a type-safe cast. This is eligible because immutable/read-only collections are covariant.- Type Parameters:
K- Key typeV- Value type- Parameters:
map- ASortedMultimap.- Returns:
- the given
multimapinstance as narrowed typeSortedMultimap<K, V>.
-
filter
SortedMultimap<K,V> filter(@NonNull java.util.function.BiPredicate<? super K,? super V> predicate)
Description copied from interface:MultimapReturns a new Multimap consisting of all elements which satisfy the given predicate.
-
reject
SortedMultimap<K,V> reject(@NonNull java.util.function.BiPredicate<? super K,? super V> predicate)
Description copied from interface:MultimapReturns a new Multimap consisting of all elements which do not satisfy the given predicate.
-
filterKeys
SortedMultimap<K,V> filterKeys(@NonNull java.util.function.Predicate<? super K> predicate)
Description copied from interface:MultimapReturns a new Multimap consisting of all elements with keys which satisfy the given predicate.- Specified by:
filterKeysin interfaceMultimap<K,V>- Parameters:
predicate- the predicate used to test keys of elements- Returns:
- a new Multimap
-
rejectKeys
SortedMultimap<K,V> rejectKeys(@NonNull java.util.function.Predicate<? super K> predicate)
Description copied from interface:MultimapReturns a new Multimap consisting of all elements with keys which do not satisfy the given predicate.- Specified by:
rejectKeysin interfaceMultimap<K,V>- Parameters:
predicate- the predicate used to test keys of elements- Returns:
- a new Multimap
-
filterValues
SortedMultimap<K,V> filterValues(@NonNull java.util.function.Predicate<? super V> predicate)
Description copied from interface:MultimapReturns a new Multimap consisting of all elements with values which satisfy the given predicate.- Specified by:
filterValuesin interfaceMultimap<K,V>- Parameters:
predicate- the predicate used to test values of elements- Returns:
- a new Multimap
-
rejectValues
SortedMultimap<K,V> rejectValues(@NonNull java.util.function.Predicate<? super V> predicate)
Description copied from interface:MultimapReturns a new Multimap consisting of all elements with values which do not satisfy the given predicate.- Specified by:
rejectValuesin interfaceMultimap<K,V>- Parameters:
predicate- the predicate used to test values of elements- Returns:
- a new Multimap
-
keySet
SortedSet<K> keySet()
Description copied from interface:MultimapReturns the keys contained in this multimap.
-
merge
SortedMultimap<K,V> merge(@NonNull Multimap<? extends K,? extends V> that)
Description copied from interface:MultimapCreates a new multimap which by merging the entries ofthismultimap andthatmultimap.If collisions occur, the value of
thismultimap is taken.
-
merge
<K2 extends K,V2 extends V> SortedMultimap<K,V> merge(@NonNull Multimap<K2,V2> that, @NonNull java.util.function.BiFunction<Traversable<V>,Traversable<V2>,Traversable<V>> collisionResolution)
Description copied from interface:MultimapCreates a new multimap which by merging the entries ofthismultimap andthatmultimap.Uses the specified collision resolution function if two keys are the same. The collision resolution function will always take the first argument from
thismultimap and the second fromthatmultimap.
-
put
SortedMultimap<K,V> put(K key, V value)
Description copied from interface:MultimapAssociates the specified value with the specified key in this multimap. If the map previously contained a mapping for the key, the old value is replaced by the specified value.
-
put
SortedMultimap<K,V> put(@NonNull Tuple2<? extends K,? extends V> entry)
Description copied from interface:MultimapConvenience method forput(entry._1, entry._2).
-
remove
SortedMultimap<K,V> remove(K key)
Description copied from interface:MultimapRemoves the mapping for a key from this multimap if it is present.
-
remove
SortedMultimap<K,V> remove(K key, V value)
Description copied from interface:MultimapRemoves the key-value pair from this multimap if it is present.
-
removeAll
@Deprecated SortedMultimap<K,V> removeAll(@NonNull java.util.function.BiPredicate<? super K,? super V> predicate)
Deprecated.Description copied from interface:MultimapReturns a new Multimap consisting of all elements which do not satisfy the given predicate.
-
removeAll
SortedMultimap<K,V> removeAll(@NonNull java.lang.Iterable<? extends K> keys)
Description copied from interface:MultimapRemoves the mapping for a key from this multimap if it is present.
-
removeKeys
@Deprecated SortedMultimap<K,V> removeKeys(@NonNull java.util.function.Predicate<? super K> predicate)
Deprecated.Description copied from interface:MultimapReturns a new Multimap consisting of all elements with keys which do not satisfy the given predicate.- Specified by:
removeKeysin interfaceMultimap<K,V>- Parameters:
predicate- the predicate used to test keys of elements- Returns:
- a new Multimap
-
removeValues
@Deprecated SortedMultimap<K,V> removeValues(@NonNull java.util.function.Predicate<? super V> predicate)
Deprecated.Description copied from interface:MultimapReturns a new Multimap consisting of all elements with values which do not satisfy the given predicate.- Specified by:
removeValuesin interfaceMultimap<K,V>- Parameters:
predicate- the predicate used to test values of elements- Returns:
- a new Multimap
-
toJavaMap
java.util.SortedMap<K,java.util.Collection<V>> toJavaMap()
Description copied from interface:MultimapConverts this VavrMapto ajava.util.Mapwhile preserving characteristics like insertion order (LinkedHashMultimap) and sort order (SortedMultimap).
-
distinct
SortedMultimap<K,V> distinct()
Description copied from interface:TraversableReturns a newTraversablecontaining the elements of this instance with all duplicates removed. Element equality is determined usingequals.
-
distinctBy
SortedMultimap<K,V> distinctBy(@NonNull java.util.Comparator<? super Tuple2<K,V>> comparator)
Description copied from interface:TraversableReturns a newTraversablecontaining the elements of this instance without duplicates, as determined by the givencomparator.- Specified by:
distinctByin interfaceMultimap<K,V>- Specified by:
distinctByin interfaceTraversable<K>- Parameters:
comparator- a comparator used to determine equality of elements- Returns:
- a new
Traversablewith duplicates removed
-
distinctBy
<U> SortedMultimap<K,V> distinctBy(@NonNull java.util.function.Function<? super Tuple2<K,V>,? extends U> keyExtractor)
Description copied from interface:TraversableReturns a newTraversablecontaining the elements of this instance without duplicates, based on keys extracted from elements usingkeyExtractor.The first occurrence of each key is retained in the resulting sequence.
- Specified by:
distinctByin interfaceMultimap<K,V>- Specified by:
distinctByin interfaceTraversable<K>- Type Parameters:
U- the type of key- Parameters:
keyExtractor- a function to extract keys for determining uniqueness- Returns:
- a new
Traversablewith duplicates removed based on keys
-
drop
SortedMultimap<K,V> drop(int n)
Description copied from interface:TraversableReturns a newTraversablewithout the firstnelements, or an empty instance if this contains fewer thannelements.
-
dropRight
SortedMultimap<K,V> dropRight(int n)
Description copied from interface:TraversableReturns a newTraversablewithout the lastnelements, or an empty instance if this contains fewer thannelements.
-
dropUntil
SortedMultimap<K,V> dropUntil(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Description copied from interface:TraversableReturns a newTraversablestarting from the first element that satisfies the givenpredicate, dropping all preceding elements.
-
dropWhile
SortedMultimap<K,V> dropWhile(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Description copied from interface:TraversableReturns a newTraversablestarting from the first element that does not satisfy the givenpredicate, dropping all preceding elements.This is equivalent to
dropUntil(predicate.negate()), which is useful for method references that cannot be negated directly.
-
filter
SortedMultimap<K,V> filter(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Description copied from interface:TraversableReturns a new traversable containing only the elements that satisfy the given predicate.
-
reject
SortedMultimap<K,V> reject(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Description copied from interface:TraversableReturns a new traversable containing only the elements that do not satisfy the given predicate.This is equivalent to
filter(predicate.negate()).
-
groupBy
<C> Map<C,? extends SortedMultimap<K,V>> groupBy(@NonNull java.util.function.Function<? super Tuple2<K,V>,? extends C> classifier)
Description copied from interface:TraversableGroups elements of thisTraversablebased on a classifier function.- Specified by:
groupByin interfaceMultimap<K,V>- Specified by:
groupByin interfaceTraversable<K>- Type Parameters:
C- The type of the group keys- Parameters:
classifier- A function that assigns each element to a group- Returns:
- A map where each key corresponds to a group of elements
- See Also:
Traversable.arrangeBy(Function)
-
grouped
Iterator<? extends SortedMultimap<K,V>> grouped(int size)
Description copied from interface:TraversableSplits thisTraversableinto consecutive blocks of the given size.Let
lengthbe the number of elements in thisTraversable:- If empty, the resulting
Iteratoris empty. - If
size <= length, the resultingIteratorcontainslength / sizeblocks of sizesizeand possibly a final smaller block of sizelength % size. - If
size > length, the resultingIteratorcontains a single block of sizelength.
Examples:
[].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]]Note:
grouped(size)is equivalent tosliding(size, size). - If empty, the resulting
-
init
SortedMultimap<K,V> init()
Description copied from interface:TraversableReturns all elements of this Traversable except the last one.This is the dual of
Traversable.tail().
-
initOption
Option<? extends SortedMultimap<K,V>> initOption()
Description copied from interface:TraversableReturns all elements of this Traversable except the last one, wrapped in anOption.This is the dual of
Traversable.tailOption().- Specified by:
initOptionin interfaceMultimap<K,V>- Specified by:
initOptionin interfaceTraversable<K>- Returns:
Some(traversable)if non-empty, orNoneif this Traversable is empty
-
orElse
SortedMultimap<K,V> orElse(java.lang.Iterable<? extends Tuple2<K,V>> other)
Description copied from interface:TraversableReturns thisTraversableif it is non-empty; otherwise, returns the given alternative.
-
orElse
SortedMultimap<K,V> orElse(@NonNull java.util.function.Supplier<? extends java.lang.Iterable<? extends Tuple2<K,V>>> supplier)
Description copied from interface:TraversableReturns thisTraversableif it is non-empty; otherwise, returns the result of evaluating the given supplier.
-
partition
Tuple2<? extends SortedMultimap<K,V>,? extends SortedMultimap<K,V>> partition(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Description copied from interface:TraversableSplits thisTraversableinto two partitions according to a predicate.The first partition contains all elements that satisfy the predicate, and the second contains all elements that do not. The original iteration order is preserved.
-
peek
SortedMultimap<K,V> peek(@NonNull java.util.function.Consumer<? super Tuple2<K,V>> action)
Description copied from interface:ValuePerforms the givenactionon the first element if this is an eager implementation. Performs the givenactionon all elements (the first immediately, successive deferred), if this is a lazy implementation.
-
replace
SortedMultimap<K,V> replace(@NonNull Tuple2<K,V> currentElement, Tuple2<K,V> newElement)
Description copied from interface:TraversableReplaces the first occurrence ofcurrentElementwithnewElement, if it exists.
-
replaceAll
SortedMultimap<K,V> replaceAll(@NonNull Tuple2<K,V> currentElement, Tuple2<K,V> newElement)
Description copied from interface:TraversableReplaces all occurrences ofcurrentElementwithnewElement.- Specified by:
replaceAllin interfaceMultimap<K,V>- Specified by:
replaceAllin interfaceTraversable<K>- Parameters:
currentElement- the element to be replacednewElement- the replacement element- Returns:
- a new Traversable with all occurrences of
currentElementreplaced bynewElement
-
replaceValue
SortedMultimap<K,V> replaceValue(K key, V value)
Description copied from interface:MultimapReplaces the entry for the specified key only if it is currently mapped to some value.- Specified by:
replaceValuein interfaceMultimap<K,V>- Parameters:
key- the key of the element to be substitutedvalue- the new value to be associated with the key- Returns:
- a new map containing key mapped to value if key was contained before. The old map otherwise
-
replace
SortedMultimap<K,V> replace(K key, V oldValue, V newValue)
Description copied from interface:MultimapReplaces the entry with the specified key and oldValue.- Specified by:
replacein interfaceMultimap<K,V>- Parameters:
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 key- Returns:
- a new map containing key mapped to newValue if key was contained before and oldValue was associated with the key. The old map otherwise.
-
replaceAll
SortedMultimap<K,V> replaceAll(@NonNull java.util.function.BiFunction<? super K,? super V,? extends V> function)
Description copied from interface:MultimapReplaces 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.- Specified by:
replaceAllin interfaceMultimap<K,V>- Parameters:
function- function transforming key and current value to a new value- Returns:
- a new map with the same keySet but transformed values
-
retainAll
SortedMultimap<K,V> retainAll(@NonNull java.lang.Iterable<? extends Tuple2<K,V>> elements)
Description copied from interface:TraversableRetains only the elements from this Traversable that are contained in the givenelements.
-
scan
SortedMultimap<K,V> scan(Tuple2<K,V> zero, @NonNull java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K,V>,? extends Tuple2<K,V>> operation)
Description copied from interface:TraversableComputes a prefix scan of the elements of this Traversable.The neutral element
zeromay be applied more than once.
-
slideBy
Iterator<? extends SortedMultimap<K,V>> slideBy(@NonNull java.util.function.Function<? super Tuple2<K,V>,?> classifier)
Description copied from interface:TraversablePartitions thisTraversableinto consecutive non-overlapping windows according to a classification function.Each window contains elements with the same class, as determined by
classifier. Two consecutive elements belong to the same window only ifclassifierreturns equal values for both. Otherwise, the current window ends and a new window begins with the next element.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]]
-
sliding
Iterator<? extends SortedMultimap<K,V>> sliding(int size)
Description copied from interface:TraversableSlides a window of a givensizeover thisTraversablewith a step size of 1.This is equivalent to calling
Traversable.sliding(int, int)with a step size of 1.
-
sliding
Iterator<? extends SortedMultimap<K,V>> sliding(int size, int step)
Description copied from interface:TraversableSlides a window of a specificsizewith a givenstepover thisTraversable.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]]
-
span
Tuple2<? extends SortedMultimap<K,V>,? extends SortedMultimap<K,V>> span(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Description copied from interface:TraversableSplits thisTraversableinto a prefix and remainder according to the givenpredicate.The first element of the returned
Tupleis the longest prefix of elements satisfyingpredicate, and the second element is the remaining elements.
-
tail
SortedMultimap<K,V> tail()
Description copied from interface:TraversableReturns a newTraversablewithout its first element.
-
tailOption
Option<? extends SortedMultimap<K,V>> tailOption()
Description copied from interface:TraversableReturns a newTraversablewithout its first element as anOption.- Specified by:
tailOptionin interfaceMultimap<K,V>- Specified by:
tailOptionin interfaceTraversable<K>- Returns:
Some(traversable)if non-empty, otherwiseNone
-
take
SortedMultimap<K,V> take(int n)
Description copied from interface:TraversableReturns the firstnelements of thisTraversable, or all elements ifnexceeds the length.Equivalent to
sublist(0, max(0, min(length(), n))), but safe forn < 0orn > length().If
n < 0, an empty instance is returned. Ifn > length(), the full instance is returned.
-
takeRight
SortedMultimap<K,V> takeRight(int n)
Description copied from interface:TraversableReturns the lastnelements of thisTraversable, or all elements ifnexceeds the length.Equivalent to
sublist(max(0, length() - n), length()), but safe forn < 0orn > length().If
n < 0, an empty instance is returned. Ifn > length(), the full instance is returned.
-
takeUntil
SortedMultimap<K,V> takeUntil(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Description copied from interface:TraversableTakes elements from thisTraversableuntil the given predicate holds for an element.Equivalent to
takeWhile(predicate.negate()), but useful when using method references that cannot be negated directly.
-
takeWhile
SortedMultimap<K,V> takeWhile(@NonNull java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Description copied from interface:TraversableTakes elements from thisTraversablewhile the given predicate holds.- Specified by:
takeWhilein interfaceMultimap<K,V>- Specified by:
takeWhilein interfaceTraversable<K>- Parameters:
predicate- a condition tested sequentially on the elements- Returns:
- a new
Traversablecontaining all elements up to (but not including) the first one that does not satisfy the predicate
-
-