FloatList
-
Cmn
sealed class FloatList
MutableFloatList |
|
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.
Summary
Public functions |
||
|---|---|---|
inline Boolean |
any()Returns |
Cmn
|
inline Boolean |
Returns |
Cmn
|
Int |
binarySearch(element: Int, fromIndex: Int, toIndex: Int)Searches this list the specified element in the range defined by |
Cmn
|
operator Boolean |
Returns |
Cmn
|
Boolean |
containsAll(elements: FloatList)Returns |
Cmn
|
inline Int |
count()Returns the number of elements in this list. |
Cmn
|
inline Int |
Counts the number of elements matching |
Cmn
|
Float |
Returns the element at the given |
Cmn
|
inline Float |
elementAtOrElse(Returns the element at the given |
Cmn
|
open operator Boolean |
Returns |
Cmn
|
Float |
first()Returns the first element in the |
Cmn
|
inline Float |
Returns the first element in the |
Cmn
|
inline R |
Accumulates values, starting with |
Cmn
|
inline R |
<R : Any?> foldIndexed(initial: R, operation: (index: Int, acc, element: Float) -> R)Accumulates values, starting with |
Cmn
|
inline R |
Accumulates values, starting with |
Cmn
|
inline R |
<R : Any?> foldRightIndexed(Accumulates values, starting with |
Cmn
|
inline Unit |
Cmn
|
|
inline Unit |
forEachIndexed(block: (index: Int, element: Float) -> Unit)Calls |
Cmn
|
inline Unit |
forEachReversed(block: (element: Float) -> Unit)Calls |
Cmn
|
inline Unit |
forEachReversedIndexed(block: (index: Int, element: Float) -> Unit)Calls |
Cmn
|
operator Float |
Returns the element at the given |
Cmn
|
open Int |
hashCode()Returns a hash code based on the contents of the |
Cmn
|
Int |
Returns the index of |
Cmn
|
inline Int |
indexOfFirst(predicate: (element: Float) -> Boolean)Returns the index if the first element in the |
Cmn
|
inline Int |
indexOfLast(predicate: (element: Float) -> Boolean)Returns the index if the last element in the |
Cmn
|
inline Boolean |
isEmpty()Returns |
Cmn
|
inline Boolean |
Returns |
Cmn
|
String |
joinToString(Creates a String from the elements separated by |
Cmn
|
inline String |
joinToString(Creates a String from the elements separated by |
Cmn
|
Float |
last()Returns the last element in the |
Cmn
|
inline Float |
Returns the last element in the |
Cmn
|
Int |
lastIndexOf(element: Float)Returns the index of the last element in the |
Cmn
|
inline Boolean |
none()Returns |
Cmn
|
inline Boolean |
reversedAny(predicate: (element: Float) -> Boolean)Returns |
Cmn
|
open String |
toString()Returns a String representation of the list, surrounded by "[]" and each element separated by ", ". |
Cmn
|
Public properties |
||
|---|---|---|
IntRange |
Returns an |
Cmn
|
Int |
Returns the last valid index in the |
Cmn
|
Int |
The number of elements in the |
Cmn
|
Public functions
any
inline fun any(predicate: (element: Float) -> Boolean): Boolean
Returns true if any of the elements give a true return value for predicate.
binarySearch
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.
fromIndex must be >= 0 and <toIndex, and toIndex must be <= size, otherwise an an IndexOutOfBoundsException will be thrown.
| Returns | |
|---|---|
Int |
the index of the element if it is contained in the list within the specified range. otherwise, the inverted insertion point |
contains
operator fun contains(element: Float): Boolean
Returns true if the FloatList contains element or false otherwise.
containsAll
fun containsAll(elements: FloatList): Boolean
Returns true if the FloatList contains all elements in elements or false if one or more are missing.
count
inline fun count(predicate: (element: Float) -> Boolean): Int
Counts the number of elements matching predicate.
elementAt
fun elementAt(index: @IntRange(from = 0) Int): Float
Returns the element at the given index or throws IndexOutOfBoundsException if the index is out of bounds of this collection.
elementAtOrElse
inline fun elementAtOrElse(
index: @IntRange(from = 0) Int,
defaultValue: (index: Int) -> Float
): Float
Returns the element at the given index or defaultValue if index is out of bounds of the collection.
equals
open operator fun equals(other: Any?): Boolean
Returns true if other is a FloatList and the contents of this and other are the same.
first
fun first(): Float
Returns the first element in the FloatList or throws a NoSuchElementException if it isEmpty.
first
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.
| See also | |
|---|---|
indexOfFirst |
fold
inline fun <R : Any?> fold(initial: R, operation: (acc, element: Float) -> R): R
Accumulates values, starting with initial, and applying operation to each element in the FloatList in order.
foldIndexed
inline fun <R : Any?> foldIndexed(initial: R, operation: (index: Int, acc, element: Float) -> R): R
Accumulates values, starting with initial, and applying operation to each element in the FloatList in order.
foldRight
inline fun <R : Any?> foldRight(initial: R, operation: (element: Float, acc) -> R): R
Accumulates values, starting with initial, and applying operation to each element in the FloatList in reverse order.
foldRightIndexed
inline fun <R : Any?> foldRightIndexed(
initial: R,
operation: (index: Int, element: Float, acc) -> R
): R
Accumulates values, starting with initial, and applying operation to each element in the FloatList in reverse order.
forEachIndexed
inline fun forEachIndexed(block: (index: Int, element: Float) -> Unit): Unit
Calls block for each element in the FloatList along with its index, in order.
forEachReversed
inline fun forEachReversed(block: (element: Float) -> Unit): Unit
Calls block for each element in the FloatList in reverse order.
forEachReversedIndexed
inline fun forEachReversedIndexed(block: (index: Int, element: Float) -> Unit): Unit
Calls block for each element in the FloatList along with its index, in reverse order.
get
operator fun get(index: @IntRange(from = 0) Int): Float
Returns the element at the given index or throws IndexOutOfBoundsException if the index is out of bounds of this collection.
indexOf
fun indexOf(element: Float): Int
Returns the index of element in the FloatList or -1 if element is not there.
indexOfFirst
inline fun indexOfFirst(predicate: (element: Float) -> Boolean): Int
Returns the index if the first element in the FloatList for which predicate returns true.
indexOfLast
inline fun indexOfLast(predicate: (element: Float) -> Boolean): Int
Returns the index if the last element in the FloatList for which predicate returns true.
isEmpty
inline fun isEmpty(): Boolean
Returns true if the FloatList has no elements in it or false otherwise.
isNotEmpty
inline fun isNotEmpty(): Boolean
Returns true if there are elements in the FloatList or false if it is empty.
joinToString
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.
When a non-negative value of limit is provided, a maximum of limit items are used to generate the string. If the collection holds more than limit items, the string is terminated with truncated.
joinToString
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.
When a non-negative value of limit is provided, a maximum of limit items are used to generate the string. If the collection holds more than limit items, the string is terminated with truncated.
last
fun last(): Float
Returns the last element in the FloatList or throws a NoSuchElementException if it isEmpty.
last
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.
| See also | |
|---|---|
indexOfLast |
lastIndexOf
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.
reversedAny
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.