Entry

expect interface Entry<out K, out V>(source)

Represents a key/value pair held by a Map.

Map entries obtained from the iteration of Map.entries set are not supposed to be stored separately or used long after they are obtained. The behavior of an entry is unspecified if the backing map has been modified after the entry was obtained.

To create an immutable entry not connected to any map, one can use Map.Entry.copy function.

Entry implementations must override Any.toString, Any.equals and Any.hashCode functions and provide implementations such that:

  • Entry.toString should return a string representation of the key-value pair in form of key=value.

  • Entry.equals should consider any two instances of Entry equal if their keys are equal and values are equal.

  • Entry.hashCode should be computed as exclusive or (XOR) of hash codes corresponding to a key and a value: key.hashCode() xor value.hashCode()

Since Kotlin

1.0

Parameters

K

the type of the entry key. The entry is covariant in its key type.

V

the type of the entry value. The entry is covariant in its value type.

Inheritors

actual interface Entry<out K, out V>(source)

Represents a key/value pair held by a Map.

Map entries obtained from the iteration of Map.entries set are not supposed to be stored separately or used long after they are obtained. The behavior of an entry is unspecified if the backing map has been modified after the entry was obtained.

To create an immutable entry not connected to any map, one can use Map.Entry.copy function.

Entry implementations must override Any.toString, Any.equals and Any.hashCode functions and provide implementations such that:

  • Entry.toString should return a string representation of the key-value pair in form of key=value.

  • Entry.equals should consider any two instances of Entry equal if their keys are equal and values are equal.

  • Entry.hashCode should be computed as exclusive or (XOR) of hash codes corresponding to a key and a value: key.hashCode() xor value.hashCode()

Since Kotlin

1.1

Parameters

K

the type of the entry key. The entry is covariant in its key type.

V

the type of the entry value. The entry is covariant in its value type.

Inheritors

actual interface Entry<out K, out V>(source)

Represents a key/value pair held by a Map.

Map entries obtained from the iteration of Map.entries set are not supposed to be stored separately or used long after they are obtained. The behavior of an entry is unspecified if the backing map has been modified after the entry was obtained.

To create an immutable entry not connected to any map, one can use Map.Entry.copy function.

Entry implementations must override Any.toString, Any.equals and Any.hashCode functions and provide implementations such that:

  • Entry.toString should return a string representation of the key-value pair in form of key=value.

  • Entry.equals should consider any two instances of Entry equal if their keys are equal and values are equal.

  • Entry.hashCode should be computed as exclusive or (XOR) of hash codes corresponding to a key and a value: key.hashCode() xor value.hashCode()

Since Kotlin

1.0

Parameters

K

the type of the entry key. The entry is covariant in its key type.

V

the type of the entry value. The entry is covariant in its value type.

Inheritors

actual interface Entry<out K, out V>(source)

Represents a key/value pair held by a Map.

Map entries obtained from the iteration of Map.entries set are not supposed to be stored separately or used long after they are obtained. The behavior of an entry is unspecified if the backing map has been modified after the entry was obtained.

To create an immutable entry not connected to any map, one can use Map.Entry.copy function.

Entry implementations must override Any.toString, Any.equals and Any.hashCode functions and provide implementations such that:

  • Entry.toString should return a string representation of the key-value pair in form of key=value.

  • Entry.equals should consider any two instances of Entry equal if their keys are equal and values are equal.

  • Entry.hashCode should be computed as exclusive or (XOR) of hash codes corresponding to a key and a value: key.hashCode() xor value.hashCode()

Since Kotlin

1.3

Parameters

K

the type of the entry key. The entry is covariant in its key type.

V

the type of the entry value. The entry is covariant in its value type.

Inheritors

actual interface Entry<out K, out V>(source)

Represents a key/value pair held by a Map.

Map entries obtained from the iteration of Map.entries set are not supposed to be stored separately or used long after they are obtained. The behavior of an entry is unspecified if the backing map has been modified after the entry was obtained.

To create an immutable entry not connected to any map, one can use Map.Entry.copy function.

Entry implementations must override Any.toString, Any.equals and Any.hashCode functions and provide implementations such that:

  • Entry.toString should return a string representation of the key-value pair in form of key=value.

  • Entry.equals should consider any two instances of Entry equal if their keys are equal and values are equal.

  • Entry.hashCode should be computed as exclusive or (XOR) of hash codes corresponding to a key and a value: key.hashCode() xor value.hashCode()

Since Kotlin

1.8

Parameters

K

the type of the entry key. The entry is covariant in its key type.

V

the type of the entry value. The entry is covariant in its value type.

Inheritors

actual interface Entry<out K, out V>(source)

Represents a key/value pair held by a Map.

Map entries obtained from the iteration of Map.entries set are not supposed to be stored separately or used long after they are obtained. The behavior of an entry is unspecified if the backing map has been modified after the entry was obtained.

To create an immutable entry not connected to any map, one can use Map.Entry.copy function.

Entry implementations must override Any.toString, Any.equals and Any.hashCode functions and provide implementations such that:

  • Entry.toString should return a string representation of the key-value pair in form of key=value.

  • Entry.equals should consider any two instances of Entry equal if their keys are equal and values are equal.

  • Entry.hashCode should be computed as exclusive or (XOR) of hash codes corresponding to a key and a value: key.hashCode() xor value.hashCode()

Since Kotlin

1.8

Parameters

K

the type of the entry key. The entry is covariant in its key type.

V

the type of the entry value. The entry is covariant in its value type.

Inheritors

Properties

Link copied to clipboard
expect abstract val key: K

Returns the key of this key/value pair.

Since Kotlin 1.0
actual abstract val key: K

Returns the key of this key/value pair.

Since Kotlin 1.1
actual abstract val key: K

Returns the key of this key/value pair.

Since Kotlin 1.0
actual abstract val key: K

Returns the key of this key/value pair.

Since Kotlin 1.3
actual abstract val key: K

Returns the key of this key/value pair.

Since Kotlin 1.8
actual abstract val key: K

Returns the key of this key/value pair.

Since Kotlin 1.8
Link copied to clipboard
expect abstract val value: V

Returns the value of this key/value pair.

Since Kotlin 1.0
actual abstract val value: V

Returns the value of this key/value pair.

Since Kotlin 1.1
actual abstract val value: V

Returns the value of this key/value pair.

Since Kotlin 1.0
actual abstract val value: V

Returns the value of this key/value pair.

Since Kotlin 1.3
actual abstract val value: V

Returns the value of this key/value pair.

Since Kotlin 1.8
actual abstract val value: V

Returns the value of this key/value pair.

Since Kotlin 1.8

Functions

Link copied to clipboard
inline operator fun <K, V> Map.Entry<K, V>.component1(): K

Returns the key component of the map entry.

Since Kotlin 1.0
Link copied to clipboard
inline operator fun <K, V> Map.Entry<K, V>.component2(): V

Returns the value component of the map entry.

Since Kotlin 1.0
Link copied to clipboard

Returns an immutable copy of this map entry with the same key and value.

Since Kotlin 2.3
Link copied to clipboard
abstract fun setValue(p0: V?): V?
Since Kotlin 1.0
Link copied to clipboard
inline fun <K, V> Map.Entry<K, V>.toPair(): Pair<K, V>

Converts this map entry to a Pair with its key being the first component and its value being the second.

Since Kotlin 1.0