IntervalList
sealed interface IntervalList<out T>
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
.
Note: this class is a part of LazyLayout
harness that allows for building custom lazy layouts.
LazyLayout and all corresponding APIs are still under development and are subject to change.
Parameters
T | type of values each interval contains in Interval.value . |
Properties
val size: Int
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.
Functions
operator fun get(index: Int): Interval<T>
Returns the interval containing the given index
.
fun forEach(fromIndex: Int = 0, toIndex: Int = size - 1, block: (Interval<T>) -> Unit)
Iterates through all the intervals starting from the one containing fromIndex
until the one
containing toIndex
.
Parameters
fromIndex | we will start iterating from the interval containing this index. |
toIndex | the last interval we iterate through will contain this index. This index should be not smaller than fromIndex . |
block | will be invoked on each interval within the defined indexes |