MutableDoubleList



MutableDoubleList is a MutableList-like collection for Double values. It allows storing and retrieving the elements without boxing. Immutable access is available through its base class DoubleList, 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

MutableDoubleList(initialCapacity: Int)

Creates a MutableDoubleList with a capacity of initialCapacity.

Cmn

Public functions

Boolean
add(element: Double)

Adds element to the MutableDoubleList and returns true.

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

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

Cmn
inline Boolean
addAll(elements: DoubleArray)

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

Cmn
inline Boolean
addAll(elements: DoubleList)

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

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

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

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

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

Cmn
Unit

Removes all elements in the MutableDoubleList.

Cmn
Unit
ensureCapacity(capacity: Int)

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

Cmn
inline operator Unit
minusAssign(element: Double)

remove from the MutableDoubleList

Cmn
operator Unit

Removes all elements from the MutableDoubleList.

Cmn
operator Unit

Removes all elements from the MutableDoubleList.

Cmn
inline operator Unit
plusAssign(element: Double)

add to the MutableDoubleList.

Cmn
inline operator Unit

Adds all elements to the end of the MutableDoubleList.

Cmn
inline operator Unit

Adds all elements to the end of the MutableDoubleList.

Cmn
Boolean
remove(element: Double)

Removes element from the MutableDoubleList.

Cmn
Boolean

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

Cmn
Boolean
removeAll(elements: DoubleList)

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

Cmn
Double
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

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

Cmn
Boolean
retainAll(elements: DoubleList)

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

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

Sets the value at index to element.

Cmn
Unit

Sorts the MutableDoubleList elements in ascending order.

Cmn
Unit

Sorts the MutableDoubleList 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 MutableDoubleList must grow.

Cmn

Inherited functions

From androidx.collection.DoubleList
inline Boolean
any()

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

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

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

Cmn
Int
binarySearch(element: Int, fromIndex: Int, toIndex: Int)

Searches this list the specified element in the range defined by fromIndex and toIndex.

Cmn
operator Boolean
contains(element: Double)

Returns true if the DoubleList contains element or false otherwise.

Cmn
Boolean

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

Cmn
inline Int

Returns the number of elements in this list.

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

Counts the number of elements matching predicate.

Cmn
Double
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 Double
elementAtOrElse(
    index: @IntRange(from = 0) Int,
    defaultValue: (index: Int) -> Double
)

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 DoubleList and the contents of this and other are the same.

Cmn
Double

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Cmn
operator Double
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 DoubleList.

Cmn
Int
indexOf(element: Double)

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

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

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

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

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

Cmn
inline Boolean

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

Cmn
inline Boolean

Returns true if there are elements in the DoubleList 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: (Double) -> CharSequence
)

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

Cmn
Double

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

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

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

Cmn
Int
lastIndexOf(element: Double)

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

Cmn
inline Boolean

Returns true if the collection has no elements in it.

Cmn
inline Boolean
reversedAny(predicate: (element: Double) -> 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.DoubleList
IntRange

Returns an IntRange of the valid indices for this DoubleList.

Cmn
Int

Returns the last valid index in the DoubleList.

Cmn
Int

The number of elements in the DoubleList.

Cmn

Public constructors

MutableDoubleList

MutableDoubleList(initialCapacity: Int = 16)

Creates a MutableDoubleList with a capacity of initialCapacity.

Public functions

add

fun add(element: Double): Boolean

Adds element to the MutableDoubleList and returns true.

add

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

Adds element to the MutableDoubleList 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

inline fun addAll(elements: DoubleArray): Boolean

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

addAll

inline fun addAll(elements: DoubleList): Boolean

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

addAll

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

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

Returns
Boolean

true if the MutableDoubleList 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: DoubleList): Boolean

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

Returns
Boolean

true if the MutableDoubleList 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 MutableDoubleList. 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 MutableDoubleList.

See also
trim

minusAssign

inline operator fun minusAssign(element: Double): Unit

remove from the MutableDoubleList

minusAssign

operator fun minusAssign(elements: DoubleArray): Unit

Removes all elements from the MutableDoubleList.

minusAssign

operator fun minusAssign(elements: DoubleList): Unit

Removes all elements from the MutableDoubleList.

plusAssign

inline operator fun plusAssign(element: Double): Unit

add to the MutableDoubleList.

plusAssign

inline operator fun plusAssign(elements: DoubleArray): Unit

Adds all elements to the end of the MutableDoubleList.

plusAssign

inline operator fun plusAssign(elements: DoubleList): Unit

Adds all elements to the end of the MutableDoubleList.

remove

fun remove(element: Double): Boolean

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

removeAll

fun removeAll(elements: DoubleArray): Boolean

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

removeAll

fun removeAll(elements: DoubleList): Boolean

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

removeAt

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

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: DoubleArray): Boolean

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

Returns
Boolean

true if the MutableDoubleList has changed.

retainAll

fun retainAll(elements: DoubleList): Boolean

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

Returns
Boolean

true if the MutableDoubleList has changed.

set

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

Sets the value at index to element.

Returns
Double

the previous value set at index

Throws
kotlin.IndexOutOfBoundsException

if index isn't between 0 and lastIndex, inclusive

sort

fun sort(): Unit

Sorts the MutableDoubleList elements in ascending order.

sortDescending

fun sortDescending(): Unit

Sorts the MutableDoubleList 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 MutableDoubleList must grow.

See also
ensureCapacity