AbstractMap
Provides a skeletal implementation of the read-only Map interface.
The implementor is required to implement entries property, which should return read-only set of map entries.
Parameters
K
- the type of map keys. The map is invariant in its key type.
V
- the type of map values. The map is covariant in its value type.
Constructors
Properties
size
open
val
size
:
Int
values
Returns a read-only Collection of all values in this map.
open
val
values
:
Collection
<
V
>
Functions
containsKey
open
fun
containsKey
(
key
:
K
)
:
Boolean
containsValue
open
fun
containsValue
(
value
:
V
)
:
Boolean
equals
Compares this map with other instance with the ordered structural equality.
open
fun
equals
(
other
:
Any
?
)
:
Boolean
get
open
operator
fun
get
(
key
:
K
)
:
V
?
hashCode
Returns the hash code value for this map.
open
fun
hashCode
(
)
:
Int
isEmpty
open
fun
isEmpty
(
)
:
Boolean
toString
Returns a string representation of the object.
open
fun
toString
(
)
:
String
Extension Functions
contains
Checks if the map contains the given key.
operator
fun
<
K
,
V
>
Map
<
out
K
,
V
>
.
contains
(
key
:
K
)
:
Boolean
filterNotTo
Appends all entries not matching the given predicate into the given destination .
fun
<
K
,
V
,
M
:
MutableMap
<
in
K
,
in
V
>
>
Map
<
out
K
,
V
>
.
filterNotTo
(
destination
:
M
,
predicate
:
(
Entry
<
K
,
V
>
)
->
Boolean
)
:
M
filterTo
Appends all entries matching the given predicate into the mutable map given as destination parameter.
fun
<
K
,
V
,
M
:
MutableMap
<
in
K
,
in
V
>
>
Map
<
out
K
,
V
>
.
filterTo
(
destination
:
M
,
predicate
:
(
Entry
<
K
,
V
>
)
->
Boolean
)
:
M
firstNotNullOf
Returns the first non-null value produced by transform function being applied to entries of this map in iteration order, or throws NoSuchElementException if no non-null value was produced.
flatMap
Returns a single list of all elements yielded from results of transform function being invoked on each entry of original map.
flatMapTo
Appends all elements yielded from results of transform function being invoked on each entry of original map, to the given destination .
fun
<
K
,
V
,
R
,
C
:
MutableCollection
<
in
R
>
>
Map
<
out
K
,
V
>
.
flatMapTo
(
destination
:
C
,
transform
:
(
Entry
<
K
,
V
>
)
->
Iterable
<
R
>
)
:
C
fun
<
K
,
V
,
R
,
C
:
MutableCollection
<
in
R
>
>
Map
<
out
K
,
V
>
.
flatMapTo
(
destination
:
C
,
transform
:
(
Entry
<
K
,
V
>
)
->
Sequence
<
R
>
)
:
C
getOrElse
Returns the value for the given
key
if the value is present and not
null
.
Otherwise, returns the result of the
defaultValue
function.
fun
<
K
,
V
>
Map
<
K
,
V
>
.
getOrElse
(
key
:
K
,
defaultValue
:
(
)
->
V
)
:
V
getValue
Returns the value of the property for the given object from this read-only map.
ifEmpty
Returns this map if it's not empty or the result of calling defaultValue function if the map is empty.
fun
<
M
,
R
>
M
.
ifEmpty
(
defaultValue
:
(
)
->
R
)
:
R
where
M
:
Map
<
*
,
*
>
,
M
:
R
isNotEmpty
Returns
true
if this map is not empty.
fun
<
K
,
V
>
Map
<
out
K
,
V
>
.
isNotEmpty
(
)
:
Boolean
isNullOrEmpty
Returns
true
if this nullable map is either null or empty.
fun
<
K
,
V
>
Map
<
out
K
,
V
>
?
.
isNullOrEmpty
(
)
:
Boolean
mapKeysTo
Populates the given destination map with entries having the keys obtained by applying the transform function to each entry in this Map and the values of this map.
fun
<
K
,
V
,
R
,
M
:
MutableMap
<
in
R
,
in
V
>
>
Map
<
out
K
,
V
>
.
mapKeysTo
(
destination
:
M
,
transform
:
(
Entry
<
K
,
V
>
)
->
R
)
:
M
mapNotNullTo
Applies the given transform function to each entry in the original map and appends only the non-null results to the given destination .
fun
<
K
,
V
,
R
:
Any
,
C
:
MutableCollection
<
in
R
>
>
Map
<
out
K
,
V
>
.
mapNotNullTo
(
destination
:
C
,
transform
:
(
Entry
<
K
,
V
>
)
->
R
?
)
:
C
mapTo
Applies the given transform function to each entry of the original map and appends the results to the given destination .
fun
<
K
,
V
,
R
,
C
:
MutableCollection
<
in
R
>
>
Map
<
out
K
,
V
>
.
mapTo
(
destination
:
C
,
transform
:
(
Entry
<
K
,
V
>
)
->
R
)
:
C
mapValuesTo
Populates the given destination map with entries having the keys of this map and the values obtained by applying the transform function to each entry in this Map .
fun
<
K
,
V
,
R
,
M
:
MutableMap
<
in
K
,
in
R
>
>
Map
<
out
K
,
V
>
.
mapValuesTo
(
destination
:
M
,
transform
:
(
Entry
<
K
,
V
>
)
->
R
)
:
M
maxByOrNull
Returns the first entry yielding the largest value of the given function or
null
if there are no entries.
fun
<
K
,
V
,
R
:
Comparable
<
R
>
>
Map
<
out
K
,
V
>
.
maxByOrNull
(
selector
:
(
Entry
<
K
,
V
>
)
->
R
)
:
Entry
<
K
,
V
>
?
maxOf
Returns the largest value among all values produced by selector function applied to each entry in the map.
fun
<
K
,
V
,
R
:
Comparable
<
R
>
>
Map
<
out
K
,
V
>
.
maxOf
(
selector
:
(
Entry
<
K
,
V
>
)
->
R
)
:
R
maxOfOrNull
Returns the largest value among all values produced by
selector
function
applied to each entry in the map or
null
if there are no entries.
fun
<
K
,
V
,
R
:
Comparable
<
R
>
>
Map
<
out
K
,
V
>
.
maxOfOrNull
(
selector
:
(
Entry
<
K
,
V
>
)
->
R
)
:
R
?
maxOfWith
Returns the largest value according to the provided comparator among all values produced by selector function applied to each entry in the map.
fun
<
K
,
V
,
R
>
Map
<
out
K
,
V
>
.
maxOfWith
(
comparator
:
Comparator
<
in
R
>
,
selector
:
(
Entry
<
K
,
V
>
)
->
R
)
:
R
maxOfWithOrNull
Returns the largest value according to the provided
comparator
among all values produced by
selector
function applied to each entry in the map or
null
if there are no entries.
fun
<
K
,
V
,
R
>
Map
<
out
K
,
V
>
.
maxOfWithOrNull
(
comparator
:
Comparator
<
in
R
>
,
selector
:
(
Entry
<
K
,
V
>
)
->
R
)
:
R
?
maxWith
Returns the first entry having the largest value according to the provided comparator .
fun
<
K
,
V
>
Map
<
out
K
,
V
>
.
maxWith
(
comparator
:
Comparator
<
in
Entry
<
K
,
V
>
>
)
:
Entry
<
K
,
V
>
maxWithOrNull
Returns the first entry having the largest value according to the provided
comparator
or
null
if there are no entries.
fun
<
K
,
V
>
Map
<
out
K
,
V
>
.
maxWithOrNull
(
comparator
:
Comparator
<
in
Entry
<
K
,
V
>
>
)
:
Entry
<
K
,
V
>
?
minByOrNull
Returns the first entry yielding the smallest value of the given function or
null
if there are no entries.
fun
<
K
,
V
,
R
:
Comparable
<
R
>
>
Map
<
out
K
,
V
>
.
minByOrNull
(
selector
:
(
Entry
<
K
,
V
>
)
->
R
)
:
Entry
<
K
,
V
>
?
minOf
Returns the smallest value among all values produced by selector function applied to each entry in the map.
fun
<
K
,
V
,
R
:
Comparable
<
R
>
>
Map
<
out
K
,
V
>
.
minOf
(
selector
:
(
Entry
<
K
,
V
>
)
->
R
)
:
R
minOfOrNull
Returns the smallest value among all values produced by
selector
function
applied to each entry in the map or
null
if there are no entries.
fun
<
K
,
V
,
R
:
Comparable
<
R
>
>
Map
<
out
K
,
V
>
.
minOfOrNull
(
selector
:
(
Entry
<
K
,
V
>
)
->
R
)
:
R
?
minOfWith
Returns the smallest value according to the provided comparator among all values produced by selector function applied to each entry in the map.
fun
<
K
,
V
,
R
>
Map
<
out
K
,
V
>
.
minOfWith
(
comparator
:
Comparator
<
in
R
>
,
selector
:
(
Entry
<
K
,
V
>
)
->
R
)
:
R
minOfWithOrNull
Returns the smallest value according to the provided
comparator
among all values produced by
selector
function applied to each entry in the map or
null
if there are no entries.
fun
<
K
,
V
,
R
>
Map
<
out
K
,
V
>
.
minOfWithOrNull
(
comparator
:
Comparator
<
in
R
>
,
selector
:
(
Entry
<
K
,
V
>
)
->
R
)
:
R
?
minus
Returns a map containing all entries of the original map except the entry with the given key .
Returns a map containing all entries of the original map except those entries the keys of which are contained in the given keys collection.
Returns a map containing all entries of the original map except those entries the keys of which are contained in the given keys array.
minWith
Returns the first entry having the smallest value according to the provided comparator .
fun
<
K
,
V
>
Map
<
out
K
,
V
>
.
minWith
(
comparator
:
Comparator
<
in
Entry
<
K
,
V
>
>
)
:
Entry
<
K
,
V
>
minWithOrNull
Returns the first entry having the smallest value according to the provided
comparator
or
null
if there are no entries.
fun
<
K
,
V
>
Map
<
out
K
,
V
>
.
minWithOrNull
(
comparator
:
Comparator
<
in
Entry
<
K
,
V
>
>
)
:
Entry
<
K
,
V
>
?
plus
Creates a new read-only map by replacing or adding an entry to this map from a given key-value pair .
Creates a new read-only map by replacing or adding entries to this map from a given collection of key-value pairs .
Creates a new read-only map by replacing or adding entries to this map from a given array of key-value pairs .
Creates a new read-only map by replacing or adding entries to this map from a given sequence of key-value pairs .
toMap
Returns a new read-only map containing all key-value pairs from the original map.
Populates and returns the destination mutable map with key-value pairs from the given map.
fun
<
K
,
V
,
M
:
MutableMap
<
in
K
,
in
V
>
>
Map
<
out
K
,
V
>
.
toMap
(
destination
:
M
)
:
M
toMutableMap
Returns a new mutable map containing all key-value pairs from the original map.
fun
<
K
,
V
>
Map
<
out
K
,
V
>
.
toMutableMap
(
)
:
MutableMap
<
K
,
V
>
withDefault
Returns a wrapper of this read-only map, having the implicit default value provided with the specified function defaultValue .
Inheritors
AbstractMutableMap
Provides a skeletal implementation of the MutableMap interface.
abstract
class
AbstractMutableMap
<
K
,
V
>
:
MutableMap
<
K
,
V
>
abstract
class
AbstractMutableMap
<
K
,
V
>
:
MutableMap
<
K
,
V
>
,
AbstractMap
<
K
,
V
>
abstract
class
AbstractMutableMap
<
K
,
V
>
:
AbstractMap
<
K
,
V
>
,
MutableMap
<
K
,
V
>