Package-level declarations

Types

Link copied to clipboard
typealias ChunkedList<T> = WindowedList<T>
Link copied to clipboard

A sublist view of a sourceList that provides access to a portion of the list within the specified range (start, end). Modifications to the original list are reflected in the sublist.

Link copied to clipboard
class WindowedList<T>(sourceList: List<T>, windowSize: Int, stepSize: Int = 1, partialWindows: Boolean = false) : AbstractList<InPlaceSubList<T>>

Represents a list of windows as a list of InPlaceSubList created from a source list. Each window is a view into the original list. Changes in the original list will be reflected in the windows.

Functions

Link copied to clipboard
fun <T> List<T>.chunkedInPlace(chunkSize: Int): ChunkedList<T>

Splits this list into a list of InPlaceSubList each not exceeding the given chunkSize. The last list may have less elements than the given chunkSize.

Link copied to clipboard
fun <T> List<T>.dropInPlace(n: Int): List<T>

Returns a sublist containing all elements except first n elements. The sublist is a view into the original list. Changes in the original list will be reflected in the sublist.

Link copied to clipboard

Returns a sublist containing all elements except last n elements. The sublist is a view into the original list. Changes in the original list will be reflected in the sublist.

Link copied to clipboard
inline fun <T> List<T>.forEachChunk(chunkSize: Int, action: (InPlaceSubList<T>) -> Unit)

Iterates through the windowed chunks of this collection with given chunkSize, where window step is equals to chunkSize and calls action on each chunk.

Link copied to clipboard
inline fun <T> List<T>.forEachChunkIndexed(chunkSize: Int, action: (index: Int, InPlaceSubList<T>) -> Unit)

Iterates through the windowed chunks of this collection with given chunkSize, where window step is equals to chunkSize and calls action on each chunk with its index.

Link copied to clipboard
inline fun <T> List<T>.forEachWindow(windowSize: Int, step: Int = 1, partialWindows: Boolean = false, action: (InPlaceSubList<T>) -> Unit)

Iterates through the windows of the list and performs the given action on each window.

Link copied to clipboard
inline fun <T> List<T>.forEachWindowIndexed(windowSize: Int, step: Int = 1, partialWindows: Boolean = false, action: (index: Int, InPlaceSubList<T>) -> Unit)

Iterates through the windows of the list with their indices and performs the given action on each window.

Link copied to clipboard
fun <T> List<T>.takeInPlace(n: Int): List<T>

Returns a sublist of the first n elements. The sublist is a view into the original list. Changes in the original list will be reflected in the sublist.

Link copied to clipboard

Returns a sublist of the last n elements. The sublist is a view into the original list. Changes in the original list will be reflected in the sublist.

Link copied to clipboard
fun <T> List<T>.windowedInPlace(windowSize: Int, step: Int = 1, partialWindows: Boolean = false): WindowedList<T>

Returns a list of windows with the given windowSize sliding with the given step. Each window is a view into the original list. Changes in the original list will be reflected in the windows.