Top Description Inners Fields Constructors Methods
io.vavr.collection

pack-priv abstract Class AbstractMultimap<K, V, M extends Multimap<K, V>>

extends Object
implements Multimap<K, V>
Class Inheritance
All Implemented Interfaces
io.vavr.collection.Multimap, java.io.Serializable, io.vavr.PartialFunction, io.vavr.Function1, java.util.function.Function, io.vavr.collection.Traversable, io.vavr.Value, java.lang.Iterable, io.vavr.collection.Foldable
Known Direct Subclasses
io.vavr.collection.HashMultimap, io.vavr.collection.LinkedHashMultimap, io.vavr.collection.TreeMultimap
Type Parameters
<K>
Key type
<V>
Value type
<M>
Multimap type
Imports
io.vavr.Tuple, .Tuple2, io.vavr.control.Option, java.io.Serializable, java.util.Collection, .Comparator, .Objects, java.util.function.*

An Multimap implementation (not intended to be public).
Author
Ruslan Sennov

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static interface

Field Summary

Modifier and TypeField and Description
protected final Map<K, Traversable<V>>
private final Multimap.ContainerType
protected final AbstractMultimap.SerializableSupplier<Traversable<?>>
private static final long

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Map<K, Traversable<V>>
asMap()

Implements io.vavr.collection.Multimap.asMap.

Converts this Multimap to a Map

public <K2, V2> Multimap<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.Multimap.bimap.

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

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

Implements io.vavr.collection.Multimap.containsKey.

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

private <K2, V2> Multimap<K2, V2>
createFromEntries(Iterable<? extends Tuple2<? extends K2, ? extends V2>> entries)

protected abstract <K2, V2> Multimap<K2, V2>
createFromMap(Map<K2, Traversable<V2>> back)

public M
distinct()

Implements io.vavr.collection.Multimap.distinct.

Returns a new version of this which contains no duplicates.

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

Implements io.vavr.collection.Multimap.distinctBy.

Returns a new version of this which contains no duplicates.

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

Implements io.vavr.collection.Multimap.distinctBy.

Returns a new version of this which contains no duplicates.

public M
drop(int
The number of elements to drop.
n
)

Implements io.vavr.collection.Multimap.drop.

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

public M
dropRight(int
The number of elements to drop.
n
)

Implements io.vavr.collection.Multimap.dropRight.

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

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

Implements io.vavr.collection.Multimap.dropUntil.

Drops elements until the predicate holds for the current element.

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

Implements io.vavr.collection.Multimap.dropWhile.

Drops elements while the predicate holds for the current element.

protected abstract <K2, V2> Multimap<K2, V2>
protected abstract <K2, V2> Map<K2, V2>
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 M
filter(Predicate<? super Tuple2<K, V>>
A predicate
predicate
)

Implements io.vavr.collection.Multimap.filter.

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

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

Implements io.vavr.collection.Multimap.filter.

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

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

Implements io.vavr.collection.Multimap.filterKeys.

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

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

Implements io.vavr.collection.Multimap.filterValues.

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

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

Implements io.vavr.collection.Multimap.flatMap.

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

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

Implements io.vavr.collection.Multimap.get.

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

public Multimap.ContainerType
getContainerType()

Implements io.vavr.collection.Multimap.getContainerType.

Returns the type of the Traversable value container of this MultiMap.

public Traversable<V>
getOrElse(K
the key
key
,
Traversable<? extends V>
a default value
defaultValue
)

Implements io.vavr.collection.Multimap.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, M>
groupBy(Function<? super Tuple2<K, V>, ? extends C>
A function which classifies elements into classes
classifier
)

Implements io.vavr.collection.Multimap.groupBy.

Groups this elements by classifying the elements.

public Iterator<M>
grouped(int
a positive block size
size
)

Implements io.vavr.collection.Multimap.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 M
init()

Implements io.vavr.collection.Multimap.init.

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

public Option<M>
initOption()

Implements io.vavr.collection.Multimap.initOption.

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

public boolean
isAsync()

Implements io.vavr.Value.isAsync.

Checks if this Value is asynchronously (short: async) computed.

public boolean
isEmpty()

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

Checks if this Traversable is empty.

public boolean
isLazy()

Implements io.vavr.Value.isLazy.

Checks if this Value is lazily evaluated.

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

Implements io.vavr.collection.Multimap.iterator.

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

public Set<K>
keySet()

Implements io.vavr.collection.Multimap.keySet.

Returns the keys contained in this multimap.

public Tuple2<K, V>
last()

Implements io.vavr.collection.Traversable.last.

Dual of head(), returning the last element.

public <K2, V2> Multimap<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.Multimap.map.

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

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

Implements io.vavr.collection.Multimap.mapValues.

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

public M
merge(Multimap<? extends K, ? extends V>
the other multimap
that
)

Implements io.vavr.collection.Multimap.merge.

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

public <K2 extends K, V2 extends V> M
merge(Multimap<K2, V2>
the other multimap
that
,
BiFunction<Traversable<V>, Traversable<V2>, Traversable<V>>
the collision resolution function
collisionResolution
)

Implements io.vavr.collection.Multimap.merge.

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

public M

Returns:

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

Implements io.vavr.collection.Multimap.orElse.

Returns this Multimap if it is nonempty, otherwise Multimap created from iterable, using existing multimap properties.

public M

Returns:

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

Implements io.vavr.collection.Multimap.orElse.

Returns this Multimap if it is nonempty, otherwise Multimap created from result of evaluating supplier, using existing multimap properties.

public Tuple2<M, M>
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.Multimap.partition.

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

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

Implements io.vavr.collection.Multimap.peek.

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

public M
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.Multimap.put.

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

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

Implements io.vavr.collection.Multimap.put.

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

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

Implements io.vavr.collection.Multimap.reject.

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

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

Implements io.vavr.collection.Multimap.reject.

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

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

Implements io.vavr.collection.Multimap.rejectKeys.

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

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

Implements io.vavr.collection.Multimap.rejectValues.

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

public M
remove(K
key whose mapping is to be removed from the multimap
key
)

Implements io.vavr.collection.Multimap.remove.

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

public M
remove(K
key whose mapping is to be removed from the multimap
key
,
V
value whose mapping is to be removed from the multimap
value
)

Implements io.vavr.collection.Multimap.remove.

Removes the key-value pair from this multimap if it is present.

public M
removeAll(Iterable<? extends K>
keys are to be removed from the multimap
keys
)

Implements io.vavr.collection.Multimap.removeAll.

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

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

Implements io.vavr.collection.Multimap.removeAll.

Deprecated

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

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

Implements io.vavr.collection.Multimap.removeKeys.

Deprecated

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

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

Implements io.vavr.collection.Multimap.removeValues.

Deprecated

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

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

Implements io.vavr.collection.Multimap.replace.

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

public M
replace(K
the key of the element to be substituted
key
,
V
the expected current value associated with the key
oldValue
,
V
the new value to be associated with the key
newValue
)

Implements io.vavr.collection.Multimap.replace.

Replaces the entry with the specified key and oldValue.

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

Implements io.vavr.collection.Multimap.replaceAll.

Replaces all occurrences of the given currentElement with newElement.

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

Implements io.vavr.collection.Multimap.replaceAll.

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.

public M
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.Multimap.replaceValue.

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

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

Implements io.vavr.collection.Multimap.retainAll.

Keeps all occurrences of the given elements from this.

public M
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.Multimap.scan.

Computes a prefix scan of the elements of the collection.

public int
size()

Implements io.vavr.collection.Multimap.size.

Computes the number of elements of this Traversable.

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

Implements io.vavr.collection.Multimap.slideBy.

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

public Iterator<M>
sliding(int
a positive window size
size
)

Implements io.vavr.collection.Multimap.sliding.

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

public Iterator<M>
sliding(int
a positive window size
size
,
int
a positive step size
step
)

Implements io.vavr.collection.Multimap.sliding.

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

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

Implements io.vavr.collection.Multimap.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 M
tail()

Implements io.vavr.collection.Multimap.tail.

Drops the first element of a non-empty Traversable.

public Option<M>
tailOption()

Implements io.vavr.collection.Multimap.tailOption.

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

public M
take(int
The number of elements to take.
n
)

Implements io.vavr.collection.Multimap.take.

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

public M
takeRight(int
The number of elements to take.
n
)

Implements io.vavr.collection.Multimap.takeRight.

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

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

Implements io.vavr.collection.Multimap.takeUntil.

Takes elements until the predicate holds for the current element.

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

Implements io.vavr.collection.Multimap.takeWhile.

Takes elements while the predicate holds for the current element.

public Map<K, Collection<V>>
toJavaMap()

Implements io.vavr.collection.Multimap.toJavaMap.

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

protected <JM extends Map<K, Collection<V>>> JM
toJavaMap(JM javaMap)

public String
toString()

Overrides java.lang.Object.toString.

Implements io.vavr.Value.toString.

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

public Traversable<V>
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait