Indexed

interface Indexed<K, T>

A value of type T paired with an index of type K, i.e. a labelled/positional value.

This is a generalization of the (index, value) pairs produced by, e.g., kotlin.collections.withIndex, generic over the type of the index; see IntIndexed and LongIndexed for the concrete flavours used throughout the codebase (e.g. by Sequence.indexed and Sequence.longIndexed), and destructure it as a pair via component1/component2:

for ((index, value) in sequence.indexed()) { ... }

Type Parameters

K

is the type of the index

T

is the type of the indexed value

Inheritors

Properties

Link copied to clipboard
abstract val index: K

The index/position associated with value.

Link copied to clipboard
abstract val value: T

The indexed value.

Functions

Link copied to clipboard
open operator fun component1(): K

Destructuring component corresponding to index.

Link copied to clipboard
open operator fun component2(): T

Destructuring component corresponding to value.

Link copied to clipboard
abstract fun <R> map(mapper: (T) -> R): Indexed<K, R>

Returns a new Indexed with the same index, and value transformed via mapper.