FloatList

@Serializable(with = FloatListSerializer::class)
sealed class FloatList(source)

FloatList is a List-like collection for Float values. It allows retrieving the elements without boxing. FloatList is always backed by a MutableFloatList, its MutableList-like subclass. The purpose of this class is to avoid the performance overhead of auto-boxing due to generics since Collection classes all operate on objects.

This implementation is not thread-safe: if multiple threads access this container concurrently, and one or more threads modify the structure of the list (insertion or removal for instance), the calling code must provide the appropriate synchronization. It is also not safe to mutate during reentrancy -- in the middle of a forEach, for example. However, concurrent reads are safe.

Inheritors

Properties

Link copied to clipboard

Returns an IntRange of the valid indices for this FloatList.

Link copied to clipboard

Returns the last valid index in the FloatList. This can be -1 when the list is empty.

Link copied to clipboard
val size: Int

The number of elements in the FloatList.

Functions

Link copied to clipboard
inline fun all(predicate: (element: Float) -> Boolean): Boolean

Returns true if all elements match the given predicate.

Link copied to clipboard
inline fun any(): Boolean

Returns true if there's at least one element in the collection.

inline fun any(predicate: (element: Float) -> Boolean): Boolean

Returns true if any of the elements give a true return value for predicate.

Link copied to clipboard
inline fun atLeast(n: Int, predicate: (Float) -> Boolean): Boolean

Returns true if at least n elements in the list match the given predicate.

Link copied to clipboard
inline fun atMost(n: Int, predicate: (Float) -> Boolean): Boolean

Returns true if at most n elements in the list match the given predicate.

Link copied to clipboard
fun binarySearch(element: Int, fromIndex: Int = 0, toIndex: Int = size): Int

Searches this list the specified element in the range defined by fromIndex and toIndex. The list is expected to be sorted into ascending order according to the natural ordering of its elements, otherwise the result is undefined.

Link copied to clipboard
fun chunked(chunkSize: Int): List<FloatList>

Splits this list into chunks of specified size.

Link copied to clipboard

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

Link copied to clipboard
operator fun contains(element: Float): Boolean

Returns true if the FloatList contains element or false otherwise.

Link copied to clipboard
fun containsAll(elements: FloatList): Boolean

Returns true if the FloatList contains all elements in elements or false if one or more are missing.

Link copied to clipboard

Returns a new list that is a copy of the current list.

Link copied to clipboard
inline fun count(): Int

Returns the number of elements in this list.

inline fun count(predicate: (element: Float) -> Boolean): Int

Counts the number of elements matching predicate.

Link copied to clipboard

Returns a new list containing only distinct elements from the current list.

Link copied to clipboard
fun drop(n: Int): FloatList

Returns a new list containing all elements except first n elements.

Link copied to clipboard

Returns a new list containing all elements except last n elements.

Link copied to clipboard
inline fun dropLastWhile(predicate: (Float) -> Boolean): FloatList

Returns a new FloatList containing all elements except the last elements that satisfy the given predicate.

Link copied to clipboard
inline fun dropWhile(predicate: (Float) -> Boolean): FloatList

Returns a new list containing all elements except the first elements that satisfy the given predicate.

Link copied to clipboard
fun elementAt(index: Int): Float

Returns the element at the given index or throws IndexOutOfBoundsException if the index is out of bounds of this collection.

Link copied to clipboard
inline fun elementAtOrElse(index: Int, defaultValue: (index: Int) -> Float): Float

Returns the element at the given index or defaultValue if index is out of bounds of the collection.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

Returns true if other is a FloatList and the contents of this and other are the same.

Link copied to clipboard
inline fun filter(predicate: (Float) -> Boolean): FloatList

Returns a list containing only elements matching the given predicate.

Link copied to clipboard
fun first(): Float

Returns the first element in the FloatList or throws a NoSuchElementException if it isEmpty.

inline fun first(predicate: (element: Float) -> Boolean): Float

Returns the first element in the FloatList for which predicate returns true or throws NoSuchElementException if nothing matches.

Link copied to clipboard
inline fun <R> fold(initial: R, operation: (acc: R, element: Float) -> R): R

Accumulates values, starting with initial, and applying operation to each element in the FloatList in order.

Link copied to clipboard
inline fun <R> foldIndexed(initial: R, operation: (index: Int, acc: R, element: Float) -> R): R

Accumulates values, starting with initial, and applying operation to each element in the FloatList in order.

Link copied to clipboard
inline fun <R> foldRight(initial: R, operation: (element: Float, acc: R) -> R): R

Accumulates values, starting with initial, and applying operation to each element in the FloatList in reverse order.

Link copied to clipboard
inline fun <R> foldRightIndexed(initial: R, operation: (index: Int, element: Float, acc: R) -> R): R

Accumulates values, starting with initial, and applying operation to each element in the FloatList in reverse order.

Link copied to clipboard
inline fun forEach(block: (element: Float) -> Unit)

Calls block for each element in the FloatList, in order.

Link copied to clipboard
inline fun FloatList.forEachChunk(chunkSize: Int, action: (InPlaceFloatSubList) -> 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 FloatList.forEachChunkIndexed(chunkSize: Int, action: (index: Int, InPlaceFloatSubList) -> 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 forEachIndexed(block: (index: Int, element: Float) -> Unit)

Calls block for each element in the FloatList along with its index, in order.

Link copied to clipboard
inline fun forEachReversed(block: (element: Float) -> Unit)

Calls block for each element in the FloatList in reverse order.

Link copied to clipboard
inline fun forEachReversedIndexed(block: (index: Int, element: Float) -> Unit)

Calls block for each element in the FloatList along with its index, in reverse order.

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

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

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

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

Link copied to clipboard
operator fun get(index: Int): Float

Returns the element at the given index or throws IndexOutOfBoundsException if the index is out of bounds of this collection.

Link copied to clipboard
open override fun hashCode(): Int

Returns a hash code based on the contents of the FloatList.

Link copied to clipboard
fun indexOf(element: Float): Int

Returns the index of element in the FloatList or -1 if element is not there.

Link copied to clipboard
inline fun indexOfFirst(predicate: (element: Float) -> Boolean): Int

Returns the index if the first element in the FloatList for which predicate returns true.

Link copied to clipboard
inline fun indexOfLast(predicate: (element: Float) -> Boolean): Int

Returns the index if the last element in the FloatList for which predicate returns true.

Link copied to clipboard
inline fun isEmpty(): Boolean

Returns true if the FloatList has no elements in it or false otherwise.

Link copied to clipboard
inline fun isNotEmpty(): Boolean

Returns true if there are elements in the FloatList or false if it is empty.

Link copied to clipboard
fun joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "..."): String

Creates a String from the elements separated by separator and using prefix before and postfix after, if supplied.

inline fun joinToString(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "", limit: Int = -1, truncated: CharSequence = "...", crossinline transform: (Float) -> CharSequence): String

Creates a String from the elements separated by separator and using prefix before and postfix after, if supplied. transform dictates how each element will be represented.

Link copied to clipboard
fun last(): Float

Returns the last element in the FloatList or throws a NoSuchElementException if it isEmpty.

inline fun last(predicate: (element: Float) -> Boolean): Float

Returns the last element in the FloatList for which predicate returns true or throws NoSuchElementException if nothing matches.

Link copied to clipboard
fun lastIndexOf(element: Float): Int

Returns the index of the last element in the FloatList that is the same as element or -1 if no elements match.

Link copied to clipboard
inline fun <R> FloatList.map(transform: (Float) -> R): List<R>

Returns an List containing the results of applying the given transform function to each element in the original FloatList.

inline fun FloatList.map(transform: (Float) -> Double): DoubleList

Returns a DoubleList containing the results of applying the given transform function to each element in the original FloatList.

inline fun FloatList.map(transform: (Float) -> Float): FloatList

Returns a FloatList containing the results of applying the given transform function to each element in the original FloatList.

inline fun FloatList.map(transform: (Float) -> Int): IntList

Returns a IntList containing the results of applying the given transform function to each element in the original FloatList.

inline fun FloatList.map(transform: (Float) -> Long): LongList

Returns a LongList containing the results of applying the given transform function to each element in the original FloatList.

Link copied to clipboard
inline fun <R> FloatList.mapIndexed(transform: (Int, Float) -> R): List<R>

Returns a List containing the results of applying the given transform function to each element and its index in the original FloatList.

inline fun FloatList.mapIndexed(transform: (Int, Float) -> Double): DoubleList

Returns a DoubleList containing the results of applying the given transform function to each element and its index in the original FloatList.

inline fun FloatList.mapIndexed(transform: (Int, Float) -> Float): FloatList

Returns a FloatList containing the results of applying the given transform function to each element and its index in the original FloatList.

inline fun FloatList.mapIndexed(transform: (Int, Float) -> Int): IntList

Returns a IntList containing the results of applying the given transform function to each element and its index in the original FloatList.

inline fun FloatList.mapIndexed(transform: (Int, Float) -> Long): LongList

Returns a LongList containing the results of applying the given transform function to each element and its index in the original FloatList.

Link copied to clipboard
inline fun none(): Boolean

Returns true if the collection has no elements in it.

inline fun none(predicate: (element: Float) -> Boolean): Boolean

Returns true if none of the elements give a true return value for predicate.

Link copied to clipboard

Returns the FloatList itself if it's not null; otherwise returns an empty FloatList.

Link copied to clipboard

Returns a new list with all elements in reversed order.

Link copied to clipboard
inline fun reversedAll(predicate: (element: Float) -> Boolean): Boolean

Returns true if all elements match the given predicate while iterating in the reverse order.

Link copied to clipboard
inline fun reversedAny(predicate: (element: Float) -> Boolean): Boolean

Returns true if any of the elements give a true return value for predicate while iterating in the reverse order.

Link copied to clipboard

Returns a new list of all elements sorted according to natural sort order.

Link copied to clipboard

Returns a new list of all elements sorted according to descending natural sort order.

Link copied to clipboard
fun sum(): Float

Returns the sum of all elements in the list.

Link copied to clipboard
inline fun sumOf(element: (Float) -> Float): Float

Returns the sum of all elements in the list after transforming them by the given element function.

Link copied to clipboard
fun take(n: Int): FloatList

Returns a new list containing the first n elements of this list.

Link copied to clipboard

Returns a new list containing the last n elements of this list.

Link copied to clipboard
inline fun takeLastWhile(predicate: (Float) -> Boolean): FloatList

Returns a new FloatList containing the last elements that satisfy the given predicate.

Link copied to clipboard
inline fun takeWhile(predicate: (Float) -> Boolean): FloatList

Returns a new FloatList containing the first elements that satisfy the given predicate.

Link copied to clipboard

Returns a FloatArray containing all elements from this list in the same order.

Link copied to clipboard

Return a MutableSet of all elements. The returned set does NOT guarantee the element iteration order of the list.

Link copied to clipboard
fun toSet(): Set<Float>

Return a Set of all elements. The returned set does NOT guarantee the element iteration order of the list.

Link copied to clipboard
open override fun toString(): String

Returns a String representation of the list, surrounded by "[]" and each element separated by ", ".

Link copied to clipboard
fun FloatList.windowedInPlace(windowSize: Int, step: Int = 1, partialWindows: Boolean = false): WindowedFloatList

Returns a WindowedFloatList with the given windowSize sliding by step. Each window is a view into the original list.