Map interface.
Basic operations:
containsKey(Object)containsValue(Object)get(Object)keySet()merge(Map)merge(Map, BiFunction)put(Object, Object)put(Tuple2)put(Object, Object, BiFunction)put(Tuple2, BiFunction)values()| Modifier and Type | Field and Description |
|---|---|
| public static final long |
| Modifier and Type | Method and Description |
|---|---|
| public default V | apply(K
the argument key)Implements io.
Deprecated
Applies this function to the given argument and returns the result. |
| public default PartialFunction | Returns: a newPartialFunctionTurns this |
| public < key's component type of the map result K2, value's component type of the map result V2> Map | Returns: a newMapa keyMapper, Function<? super V, ? extends V2> Function that maps the keys of type K to keys of type K2a valueMapper)Function that the values of type V to values of type V2Maps this |
| public default <R> Seq | collect(PartialFunction<? super Tuple2<K, V>, ? extends R>
A function that is not necessarily defined of all elements of this traversable. partialFunction)Implements io. Collects all elements that are in the domain of the given |
| public Tuple2 | Returns: theTuple2 of current or modified map and existing or computed value associated with the specified keykey whose presence in this map is to be tested key, Function<? super K, ? extends V> mapping function mappingFunction)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 | Returns: theTuple2 of current or modified map and the Some of the value associated
with the specified key, or None if nonekey whose presence in this map is to be tested key, BiFunction<? super K, ? super V, ? extends V> remapping function remappingFunction)If the value for the specified key is present, attempts to compute a new mapping given the key and its current mapped value. |
| public default boolean | contains(Tuple2<K, V>
An Object of type A, may be null. element)Overrides default io. Shortcut for |
| public boolean | Returns: true if this map contains a mapping for the specified keykey whose presence in this map is to be tested key)Returns |
| public default boolean | Returns: true if this map maps one or more keys to the
specified valuevalue whose presence in this map is to be tested value)Returns |
| public Map | distinct()
Redeclares io. Returns a new version of this which contains no duplicates. |
| public Map | distinctBy(Comparator<? super Tuple2<K, V>>
A comparator comparator)Redeclares io. Returns a new version of this which contains no duplicates. |
| public <U> Map | distinctBy(Function<? super Tuple2<K, V>, ? extends U>
A key extractor keyExtractor)Redeclares io. Returns a new version of this which contains no duplicates. |
| public Map | drop(int
The number of elements to drop. n)Redeclares io. Drops the first n elements of this or all elements, if this length < n. |
| public Map | dropRight(int
The number of elements to drop. n)Redeclares io. Drops the last n elements of this or all elements, if this length < n. |
| public Map | dropUntil(Predicate<? super Tuple2<K, V>>
A condition tested subsequently for this elements. predicate)Redeclares io. Drops elements until the predicate holds for the current element. |
| public Map | dropWhile(Predicate<? super Tuple2<K, V>>
A condition tested subsequently for this elements. predicate)Redeclares io. Drops elements while the predicate holds for the current element. |
| public static < Key type K, Value type V> Tuple2 | Returns: a key/value pairthe entry's key key, V the entry's value value)Convenience factory method to create a key/value pair. |
| public Map | Returns: a new Mapthe predicate used to test elements predicate)Returns a new Map consisting of all elements which satisfy the given predicate. |
| public Map | filter(Predicate<? super Tuple2<K, V>>
A predicate predicate)Redeclares io. Returns a new traversable consisting of all elements which satisfy the given predicate. |
| public Map | Returns: a new Mapthe predicate used to test keys of elements predicate)Returns a new Map consisting of all elements with keys which satisfy the given predicate. |
| public Map | Returns: a new Mapthe predicate used to test values of elements predicate)Returns a new Map consisting of all elements with values which satisfy the given predicate. |
| public < key's component type of the mapped K2, Mapvalue's component type of the mapped V2> MapMap | Returns: A newMap.A mapper mapper)FlatMaps this |
| public default < Component type U> Seq | Returns: A sequence of flat-mapped values.A mapper mapper)Implements io. Flat-maps this entries to a sequence of values. |
| public default <U> U | foldRight(U
A zero element to start with. zero, BiFunction<? super Tuple2<K, V>, ? super U, ? extends U> A function which combines elements. f)Implements io. Folds this elements from the right, starting with |
| public default void | |
| public Option | Returns: theSome of value to which the specified key
is mapped, or None if this map contains no mapping
for the keythe key whose associated value is to be returned key)Returns the |
| public V | Returns: the value associated with key if it exists, otherwise the default value.the key key, V a default value defaultValue)Returns the value associated with a key, or a default value if the key is not contained in the map. |
| public <C> Map | groupBy(Function<? super Tuple2<K, V>, ? extends C>
A function which classifies elements into classes classifier)Redeclares io. Groups this elements by classifying the elements. |
| public Iterator | grouped(int
a positive block size size)Redeclares io. Groups this |
| public default boolean | hasDefiniteSize()
Implements io. Checks if this Traversable is known to have a finite size. |
| public Map | init()
Redeclares io. Dual of tail(), returning all elements except the last. |
| public Option | initOption()
Redeclares as abstract: io. Dual of tailOption(), returning all elements except the last as |
| public default boolean | isDefinedAt(K
a potential function argument key)Implements io.
Deprecated
Tests if a value is contained in the function's domain. |
| public default boolean | isDistinct()
Overrides default io. Checks if this Traversable may consist of distinct elements only. |
| public default boolean | isTraversableAgain()
Implements io. Checks if this Traversable can be repeatedly traversed. |
| public Iterator | iterator()
Redeclares as abstract: io. An iterator by means of head() and tail(). |
| public default < The type of the resulting elements U> Iterator | Returns: An iterator through the mapped elements.A function that maps (key, value) pairs to elements of type U mapper)Iterates this Map sequentially, mapping the (key, value) pairs to elements. |
| public Set | |
| public default Iterator | Returns: Iterator of the keys contained in this map.Returns the keys contained in this map as an iterator. |
| public default int | length()
Implements io. Computes the number of elements of this Traversable. |
| public default Function1 | Returns: a function that takes a key k and returns its value in a Some if found, otherwise a None.Overrides default io. Turns this map into a plain function returning an Option result. |
| public default < Component type U> Seq | Returns: A sequence of mapped values.A mapper mapper)Implements io. Maps the |
| public < key's component type of the map result K2, value's component type of the map result V2> Map | Returns: a newMapa mapper)Function that maps entries of type (K, V) to entries of type (K2, V2)Maps the entries of this |
| public < the new key type K2> Map | |
| public < the new key type K2> Map | Returns: a newMapa keyMapper, BiFunction<? super V, ? super V, ? extends V> Function that maps keys of type V to keys of type V2a valueMerge)BiFunction that merges valuesMaps the keys of this |
| public < the new value type V2> Map | |
| public Map | |
| public < value type of that Map U extends V> Map | Returns: A merged mapthe other map that, BiFunction<? super V, ? super U, ? extends V> the collision resolution function collisionResolution)Creates a new map which by merging the entries of |
| public static < Key type K, Value type V> Map | |
| public Map | orElse(Iterable<? extends Tuple2<K, V>>
An alternative other)TraversableRedeclares io. Returns this |
| public Map | orElse(Supplier<? extends Iterable<? extends Tuple2<K, V>>>
An alternative supplier)Traversable supplierRedeclares io. Returns this |
| public Tuple2 | 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. Creates a partition of this |
| public Map | peek(Consumer<? super Tuple2<K, V>>
The action that will be performed on the element(s). action)Redeclares io. Performs the given |
| public Map | Returns: A new Map containing these elements and that entry.key with which the specified value is to be associated key, V value to be associated with the specified key value)Associates the specified value with the specified key in this map. |
| public Map | |
| public < the value type U extends V> Map | Returns: A new Map containing these elements and that entry.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)Associates the specified value with the specified key in this map. |
| public < the value type U extends V> Map | Returns: A new Map containing these elements and that entry.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)Convenience method for |
| public Map | Returns: a new Mapthe predicate used to test elements predicate)Returns a new Map consisting of all elements which do not satisfy the given predicate. |
| public Map | reject(Predicate<? super Tuple2<K, V>>
A predicate predicate)Redeclares as abstract: io. Returns a new traversable consisting of all elements which do not satisfy the given predicate. |
| public Map | Returns: a new Mapthe predicate used to test keys of elements predicate)Returns a new Map consisting of all elements with keys which do not satisfy the given predicate. |
| public Map | Returns: a new Mapthe predicate used to test values of elements predicate)Returns a new Map consisting of all elements with values which do not satisfy the given predicate. |
| public Map | Returns: A new Map containing these elements without the entry specified by that key.key whose mapping is to be removed from the map key)Removes the mapping for a key from this map if it is present. |
| public Map | Returns: a new Mapthe predicate used to test elements predicate)
Deprecated
Please use
reject(BiPredicate)
Returns a new Map consisting of all elements which do not satisfy the given predicate. |
| public Map | |
| public Map | Returns: a new Mapthe predicate used to test keys of elements predicate)
Deprecated
Please use
rejectKeys(Predicate)
Returns a new Map consisting of all elements with keys which do not satisfy the given predicate. |
| public Map | Returns: a new Mapthe predicate used to test values of elements predicate)
Deprecated
Please use
rejectValues(Predicate)
Returns a new Map consisting of all elements with values which do not satisfy the given predicate. |
| public Map | replace(Tuple2<K, V>
An element to be substituted. currentElement, Tuple2<K, V> A replacement for currentElement. newElement)Redeclares io. Replaces the first occurrence (if exists) of the given currentElement with newElement. |
| public Map | Returns: a new map containing key mapped to newValue if key was contained before and oldValue matched. The old map otherwise.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)Replaces the entry for the specified key only if currently mapped to the specified value. |
| public Map | Returns: a new map with the same keySet but transformed values.function transforming key and current value to a new value function)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 Map | replaceAll(Tuple2<K, V>
An element to be substituted. currentElement, Tuple2<K, V> A replacement for currentElement. newElement)Redeclares io. Replaces all occurrences of the given currentElement with newElement. |
| public Map | Returns: a new map containing key mapped to value if key was contained before. The old map otherwise.the key of the element to be substituted. key, V the new value to be associated with the key value)Replaces the entry for the specified key only if it is currently mapped to some value. |
| public Map | retainAll(Iterable<? extends Tuple2<K, V>>
Elements to be kept. elements)Redeclares io. Keeps all occurrences of the given elements from this. |
| public Map | 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. Computes a prefix scan of the elements of the collection. |
| public default <U> Seq | scanLeft(U
the initial value zero, BiFunction<? super U, ? super Tuple2<K, V>, ? extends U> the binary operator applied to the intermediate result and the element operation)Implements io. Produces a collection containing cumulative results of applying the operator going left to right. |
| public default <U> Seq | scanRight(U
the initial value zero, BiFunction<? super Tuple2<K, V>, ? super U, ? extends U> the binary operator applied to the intermediate result and the element operation)Implements io. Produces a collection containing cumulative results of applying the operator going right to left. |
| public int | size()
Redeclares as abstract: io. Computes the number of elements of this Traversable. |
| public Iterator | slideBy(Function<? super Tuple2<K, V>, ?>
A function which classifies elements into classes classifier)Redeclares io. Slides a non-overlapping window of a variable size over this |
| public Iterator | sliding(int
a positive window size size)Redeclares io. Slides a window of a specific |
| public Iterator | sliding(int
a positive window size size, int a positive step size step)Redeclares io. Slides a window of a specific |
| public Tuple2 | span(Predicate<? super Tuple2<K, V>>
A predicate. predicate)Redeclares io. Returns a tuple where the first element is the longest prefix of elements that satisfy the given
|
| public Map | tail()
Redeclares io. Drops the first element of a non-empty Traversable. |
| public Option | tailOption()
Redeclares io. Drops the first element of a non-empty Traversable and returns an |
| public Map | take(int
The number of elements to take. n)Redeclares io. Takes the first n elements of this or all elements, if this length < n. |
| public Map | takeRight(int
The number of elements to take. n)Redeclares io. Takes the last n elements of this or all elements, if this length < n. |
| public Map | takeUntil(Predicate<? super Tuple2<K, V>>
A condition tested subsequently for this elements. predicate)Redeclares io. Takes elements until the predicate holds for the current element. |
| public Map | takeWhile(Predicate<? super Tuple2<K, V>>
A condition tested subsequently for the contained elements. predicate)Redeclares io. Takes elements while the predicate holds for the current element. |
| public Map | Returns: a newjava.util.Map instanceConverts this Vavr |
| public default < Type of transformation result U> U | |
| public default Tuple2 | |
| public default <T1, T2> Tuple2 | |
| public default <T1, T2> Tuple2 | unzip(Function<? super Tuple2<K, V>, Tuple2<? extends T1, ? extends T2>>
a function which converts elements of this to pairs unzipper)Implements io. Unzips this elements by mapping this elements to pairs which are subsequently split into two distinct sets. |
| public default <T1, T2, T3> Tuple3 | |
| public default <T1, T2, T3> Tuple3 | unzip3(Function<? super Tuple2<K, V>, Tuple3<? extends T1, ? extends T2, ? extends T3>>
a function which converts elements of this to pairs unzipper)Implements io. Unzips this elements by mapping this elements to triples which are subsequently split into three distinct sets. |
| public Seq | |
| public default Iterator | |
| public default Function1 | Returns: a total function from K to Tfunction to evaluate for all keys not present in the map defaultFunction)
Deprecated
Will be removed
Turns this map from a partial function into a total function that returns a value computed by defaultFunction for all keys absent from the map. |
| public default Function1 | Returns: a total function from K to Tdefault value to return for all keys not present in the map defaultValue)
Deprecated
Will be removed
Turns this map from a partial function into a total function that returns defaultValue for all keys absent from the map. |
| public default <U> Seq | zip(Iterable<? extends U>
The Iterable providing the second half of each result pair. that)Implements io. Returns a traversable formed from this traversable and another Iterable collection by combining corresponding elements in pairs. |
| public default <U> Seq | zipAll(Iterable<? extends U>
The Iterable providing the second half of each result pair. that, Tuple2<K, V> The element to be used to fill up the result if this traversable is shorter than that. thisElem, U The element to be used to fill up the result if that is shorter than this traversable. thatElem)Implements io. Returns a traversable formed from this traversable and another Iterable by combining corresponding elements in pairs. |
| public default <U, R> Seq | zipWith(Iterable<? extends U>
The Iterable providing the second parameter of the mapper. that, BiFunction<? super Tuple2<K, V>, ? super U, ? extends R> a mapper. mapper)Implements io. Returns a traversable formed from this traversable and another Iterable collection by mapping elements. |
| public default Seq | zipWithIndex()
Implements io. Zips this traversable with its indices. |
| public default <U> Seq | zipWithIndex(BiFunction<? super Tuple2<K, V>, ? super Integer, ? extends U>
a mapper. mapper)Implements io. Zips this traversable with its indices by applying mapper provided. |