{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

IntervalList

@ExperimentalFoundationApi
public sealed interface IntervalList<T extends Object>

Known direct subclasses
MutableIntervalList

Mutable version of IntervalList.


The list consisting of multiple intervals.

It is useful when you want to define your own dsl similar to the one used by LazyColumn where list items can be defined via multiple item/items calls.

This interface is read only, in order to create a list you need to use MutableIntervalList.

Parameters
<T extends Object>

type of values each interval contains in Interval.value.

Summary

Nested types

public final class IntervalList.Interval<T extends Object>

The interval holder.

Public methods

abstract void
forEach(
    int fromIndex,
    int toIndex,
    @NonNull Function1<@NonNull IntervalList.Interval<@NonNull T>, Unit> block
)

Iterates through all the intervals starting from the one containing fromIndex until the one containing toIndex.

abstract @NonNull IntervalList.Interval<@NonNull T>
get(int index)

Returns the interval containing the given index.

abstract int

The total amount of items in all the intervals.

Public methods

forEach

abstract void forEach(
    int fromIndex,
    int toIndex,
    @NonNull Function1<@NonNull IntervalList.Interval<@NonNull T>, Unit> block
)

Iterates through all the intervals starting from the one containing fromIndex until the one containing toIndex.

Parameters
int fromIndex

we will start iterating from the interval containing this index.

int toIndex

the last interval we iterate through will contain this index. This index should be not smaller than fromIndex.

Throws
kotlin.IndexOutOfBoundsException

if the indexes are not within 0..size - 1 range.

get

abstract @NonNull IntervalList.Interval<@NonNull T> get(int index)

Returns the interval containing the given index.

Throws
kotlin.IndexOutOfBoundsException

if the index is not within 0..size - 1 range.

getSize

abstract int getSize()

The total amount of items in all the intervals.

Note that it is not the amount of intervals, but the sum of Interval.size for all the intervals added into this list.