MutableFloatList



MutableFloatList is a MutableList-like collection for Float values. It allows storing and retrieving the elements without boxing. Immutable access is available through its base class FloatList, which has a List-like interface.

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 constructors

MutableFloatList(initialCapacity: Int)

Creates a MutableFloatList with a capacity of initialCapacity.

Cmn

Public functions

Boolean
add(element: Float)

Adds element to the MutableFloatList and returns true.

Cmn
Unit
add(index: @IntRange(from = 0) Int, element: Float)

Adds element to the MutableFloatList at the given index, shifting over any elements at index and after, if any.

Cmn
Boolean
addAll(elements: FloatArray)

Adds all elements to the end of the MutableFloatList and returns true if the MutableFloatList was changed or false if elements was empty.

Cmn
Boolean
addAll(elements: FloatList)

Adds all elements to the end of the MutableFloatList and returns true if the MutableFloatList was changed or false if elements was empty.

Cmn
Boolean
addAll(index: @IntRange(from = 0) Int, elements: FloatArray)

Adds all elements to the MutableFloatList at the given index, shifting over any elements at index and after, if any.

Cmn
Boolean
addAll(index: @IntRange(from = 0) Int, elements: FloatList)

Adds all elements to the MutableFloatList at the given index, shifting over any elements at index and after, if any.

Cmn
Unit

Removes all elements in the MutableFloatList.

Cmn
Unit
ensureCapacity(capacity: Int)

Ensures that there is enough space to store capacity elements in the MutableFloatList.

Cmn
inline operator Unit
minusAssign(element: Float)

remove from the MutableFloatList

Cmn
operator Unit

Removes all elements from the MutableFloatList.

Cmn
operator Unit

Removes all elements from the MutableFloatList.

Cmn
inline operator Unit
plusAssign(element: Float)

add to the MutableFloatList.

Cmn
operator Unit

Adds all elements to the end of the MutableFloatList.

Cmn
operator Unit
plusAssign(elements: FloatList)

Adds all elements to the end of the MutableFloatList.

Cmn
Boolean
remove(element: Float)

Removes element from the MutableFloatList.

Cmn
Boolean
removeAll(elements: FloatArray)

Removes all elements from the MutableFloatList and returns true if anything was removed.

Cmn
Boolean
removeAll(elements: FloatList)

Removes all elements from the MutableFloatList and returns true if anything was removed.

Cmn
Float
removeAt(index: @IntRange(from = 0) Int)

Removes the element at the given index and returns it.

Cmn
Unit
removeRange(start: @IntRange(from = 0) Int, end: @IntRange(from = 0) Int)

Removes items from index start (inclusive) to end (exclusive).

Cmn
Boolean
retainAll(elements: FloatArray)

Keeps only elements in the MutableFloatList and removes all other values.

Cmn
Boolean
retainAll(elements: FloatList)

Keeps only elements in the MutableFloatList and removes all other values.

Cmn
operator Float
set(index: @IntRange(from = 0) Int, element: Float)

Sets the value at index to element.

Cmn
Unit

Sorts the MutableFloatList elements in ascending order.

Cmn
Unit

Sorts the MutableFloatList elements in descending order.

Cmn
Unit
trim(minCapacity: Int)

Reduces the internal storage.

Cmn

Public properties

Int

Returns the total number of elements that can be held before the MutableFloatList must grow.

Cmn

Inherited functions

From androidx.collection.FloatList
Boolean
any()

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

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

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

Cmn
operator Boolean
contains(element: Float)

Returns true if the FloatList contains element or false otherwise.

Cmn
Boolean

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

Cmn
Int

Returns the number of elements in this list.

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

Counts the number of elements matching predicate.

Cmn
Float
elementAt(index: @IntRange(from = 0) Int)

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

Cmn
inline Float
elementAtOrElse(
    index: @IntRange(from = 0) Int,
    defaultValue: (index: Int) -> Float
)

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

Cmn
open operator Boolean
equals(other: Any?)

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

Cmn
Float

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

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

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

Cmn
inline R
<R : Any?> fold(initial: R, operation: (acc, element: Float) -> R)

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

Cmn
inline R
<R : Any?> foldIndexed(initial: R, operation: (index: Int, acc, element: Float) -> R)

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

Cmn
inline R
<R : Any?> foldRight(initial: R, operation: (element: Float, acc) -> R)

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

Cmn
inline R
<R : Any?> foldRightIndexed(
    initial: R,
    operation: (index: Int, element: Float, acc) -> R
)

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

Cmn
inline Unit
forEach(block: (element: Float) -> Unit)

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

Cmn
inline Unit
forEachIndexed(block: (index: Int, element: Float) -> Unit)

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

Cmn
inline Unit
forEachReversed(block: (element: Float) -> Unit)

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

Cmn
inline Unit
forEachReversedIndexed(block: (index: Int, element: Float) -> Unit)

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

Cmn
operator Float
get(index: @IntRange(from = 0) Int)

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

Cmn
open Int

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

Cmn
Int
indexOf(element: Float)

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

Cmn
inline Int
indexOfFirst(predicate: (element: Float) -> Boolean)

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

Cmn
inline Int
indexOfLast(predicate: (element: Float) -> Boolean)

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

Cmn
Boolean

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

Cmn
Boolean

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

Cmn
String
joinToString(
    separator: CharSequence,
    prefix: CharSequence,
    postfix: CharSequence,
    limit: Int,
    truncated: CharSequence
)

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

Cmn
inline String
joinToString(
    separator: CharSequence,
    prefix: CharSequence,
    postfix: CharSequence,
    limit: Int,
    truncated: CharSequence,
    crossinline transform: (Float) -> CharSequence
)

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

Cmn
Float

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

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

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

Cmn
Int
lastIndexOf(element: Float)

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

Cmn
Boolean

Returns true if the collection has no elements in it.

Cmn
inline Boolean
reversedAny(predicate: (element: Float) -> Boolean)

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

Cmn
open String

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

Cmn

Inherited properties

From androidx.collection.FloatList
IntRange

Returns an IntRange of the valid indices for this FloatList.

Cmn
Int

Returns the last valid index in the FloatList.

Cmn
Int

The number of elements in the FloatList.

Cmn

Public constructors

MutableFloatList

MutableFloatList(initialCapacity: Int = 16)

Creates a MutableFloatList with a capacity of initialCapacity.

Public functions

add

fun add(element: Float): Boolean

Adds element to the MutableFloatList and returns true.

add

fun add(index: @IntRange(from = 0) Int, element: Float): Unit

Adds element to the MutableFloatList at the given index, shifting over any elements at index and after, if any.

Throws
kotlin.IndexOutOfBoundsException

if index isn't between 0 and size, inclusive

addAll

fun addAll(elements: FloatArray): Boolean

Adds all elements to the end of the MutableFloatList and returns true if the MutableFloatList was changed or false if elements was empty.

addAll

fun addAll(elements: FloatList): Boolean

Adds all elements to the end of the MutableFloatList and returns true if the MutableFloatList was changed or false if elements was empty.

addAll

fun addAll(index: @IntRange(from = 0) Int, elements: FloatArray): Boolean

Adds all elements to the MutableFloatList at the given index, shifting over any elements at index and after, if any.

Returns
Boolean

true if the MutableFloatList was changed or false if elements was empty

Throws
kotlin.IndexOutOfBoundsException

if index isn't between 0 and size, inclusive.

addAll

fun addAll(index: @IntRange(from = 0) Int, elements: FloatList): Boolean

Adds all elements to the MutableFloatList at the given index, shifting over any elements at index and after, if any.

Returns
Boolean

true if the MutableFloatList was changed or false if elements was empty

Throws
kotlin.IndexOutOfBoundsException

if index isn't between 0 and size, inclusive

clear

fun clear(): Unit

Removes all elements in the MutableFloatList. The storage isn't released.

See also
trim

ensureCapacity

fun ensureCapacity(capacity: Int): Unit

Ensures that there is enough space to store capacity elements in the MutableFloatList.

See also
trim

minusAssign

inline operator fun minusAssign(element: Float): Unit

remove from the MutableFloatList

minusAssign

operator fun minusAssign(elements: FloatArray): Unit

Removes all elements from the MutableFloatList.

minusAssign

operator fun minusAssign(elements: FloatList): Unit

Removes all elements from the MutableFloatList.

plusAssign

inline operator fun plusAssign(element: Float): Unit

add to the MutableFloatList.

plusAssign

operator fun plusAssign(elements: FloatArray): Unit

Adds all elements to the end of the MutableFloatList.

plusAssign

operator fun plusAssign(elements: FloatList): Unit

Adds all elements to the end of the MutableFloatList.

remove

fun remove(element: Float): Boolean

Removes element from the MutableFloatList. If element was in the MutableFloatList and was removed, true will be returned, or false will be returned if the element was not found.

removeAll

fun removeAll(elements: FloatArray): Boolean

Removes all elements from the MutableFloatList and returns true if anything was removed.

removeAll

fun removeAll(elements: FloatList): Boolean

Removes all elements from the MutableFloatList and returns true if anything was removed.

removeAt

fun removeAt(index: @IntRange(from = 0) Int): Float

Removes the element at the given index and returns it.

Throws
kotlin.IndexOutOfBoundsException

if index isn't between 0 and lastIndex, inclusive

removeRange

fun removeRange(start: @IntRange(from = 0) Int, end: @IntRange(from = 0) Int): Unit

Removes items from index start (inclusive) to end (exclusive).

Throws
kotlin.IndexOutOfBoundsException

if start or end isn't between 0 and size, inclusive

kotlin.IllegalArgumentException

if start is greater than end

retainAll

fun retainAll(elements: FloatArray): Boolean

Keeps only elements in the MutableFloatList and removes all other values.

Returns
Boolean

true if the MutableFloatList has changed.

retainAll

fun retainAll(elements: FloatList): Boolean

Keeps only elements in the MutableFloatList and removes all other values.

Returns
Boolean

true if the MutableFloatList has changed.

set

operator fun set(index: @IntRange(from = 0) Int, element: Float): Float

Sets the value at index to element.

Returns
Float

the previous value set at index

Throws
kotlin.IndexOutOfBoundsException

if index isn't between 0 and lastIndex, inclusive

sort

fun sort(): Unit

Sorts the MutableFloatList elements in ascending order.

sortDescending

fun sortDescending(): Unit

Sorts the MutableFloatList elements in descending order.

trim

fun trim(minCapacity: Int = _size): Unit

Reduces the internal storage. If capacity is greater than minCapacity and size, the internal storage is reduced to the maximum of size and minCapacity.

See also
ensureCapacity

Public properties

capacity

val capacityInt

Returns the total number of elements that can be held before the MutableFloatList must grow.

See also
ensureCapacity