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

MutableIntervalList

@ExperimentalFoundationApi
public final class MutableIntervalList<T extends Object> implements IntervalList


Mutable version of IntervalList. It allows you to add new intervals via addInterval.

Summary

Public constructors

<T extends Object> MutableIntervalList()

Public methods

final void
addInterval(int size, @NonNull T value)

Adds a new interval into this list.

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

Allows to iterate through all the intervals starting from the one containing fromIndex until the one containing toIndex.

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

Returns the interval containing the given index.

int

The total amount of items in all the intervals.

Public constructors

MutableIntervalList

public <T extends Object> MutableIntervalList()

Public methods

addInterval

public final void addInterval(int size, @NonNull T value)

Adds a new interval into this list.

Parameters
int size

the amount of items in the new interval.

@NonNull T value

the value representing this interval.

forEach

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

Allows to iterate 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

public @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

public 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.