MutableDoubleList


public final class MutableDoubleList extends DoubleList


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(int initialCapacity)

Creates a MutableDoubleList with a capacity of initialCapacity.

Public methods

final boolean
add(double element)

Adds element to the MutableDoubleList and returns true.

final void
add(@IntRange(from = 0) int index, double element)

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

final boolean
addAll(@NonNull double[] elements)

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

final boolean

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

final boolean
addAll(@IntRange(from = 0) int index, @NonNull double[] elements)

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

final boolean
addAll(@IntRange(from = 0) int index, @NonNull DoubleList elements)

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

final void

Removes all elements in the MutableDoubleList.

final void
ensureCapacity(int capacity)

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

final int

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

final void
minusAssign(double element)

remove from the MutableDoubleList

final void
minusAssign(@NonNull double[] elements)

Removes all elements from the MutableDoubleList.

final void

Removes all elements from the MutableDoubleList.

final void
plusAssign(double element)

add to the MutableDoubleList.

final void
plusAssign(@NonNull double[] elements)

Adds all elements to the end of the MutableDoubleList.

final void

Adds all elements to the end of the MutableDoubleList.

final boolean
remove(double element)

Removes element from the MutableDoubleList.

final boolean
removeAll(@NonNull double[] elements)

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

final boolean

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

final double
removeAt(@IntRange(from = 0) int index)

Removes the element at the given index and returns it.

final void
removeRange(@IntRange(from = 0) int start, @IntRange(from = 0) int end)

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

final boolean
retainAll(@NonNull double[] elements)

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

final boolean

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

final double
set(@IntRange(from = 0) int index, double element)

Sets the value at index to element.

final void

Sorts the MutableDoubleList elements in ascending order.

final void

Sorts the MutableDoubleList elements in descending order.

final void
trim(int minCapacity)

Reduces the internal storage.

Inherited methods

From androidx.collection.DoubleList
final boolean
any()

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

final boolean
any(@NonNull Function1<@NonNull Double, @NonNull Boolean> predicate)

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

final int
binarySearch(int element, int fromIndex, int toIndex)

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

final boolean
contains(double element)

Returns true if the DoubleList contains element or false otherwise.

final boolean

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

final int

Returns the number of elements in this list.

final int
count(@NonNull Function1<@NonNull Double, @NonNull Boolean> predicate)

Counts the number of elements matching predicate.

final double
elementAt(@IntRange(from = 0) int index)

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

final double
elementAtOrElse(
    @IntRange(from = 0) int index,
    @NonNull Function1<@NonNull Integer, @NonNull Double> defaultValue
)

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

boolean
equals(Object other)

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

final double

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

final double
first(@NonNull Function1<@NonNull Double, @NonNull Boolean> predicate)

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

final @NonNull R
<R extends Object> fold(
    @NonNull R initial,
    @NonNull Function2<@NonNull acc, @NonNull Double, @NonNull R> operation
)

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

final @NonNull R
<R extends Object> foldIndexed(
    @NonNull R initial,
    @NonNull Function3<@NonNull Integer, @NonNull acc, @NonNull Double, @NonNull R> operation
)

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

final @NonNull R
<R extends Object> foldRight(
    @NonNull R initial,
    @NonNull Function2<@NonNull Double, @NonNull acc, @NonNull R> operation
)

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

final @NonNull R
<R extends Object> foldRightIndexed(
    @NonNull R initial,
    @NonNull Function3<@NonNull Integer, @NonNull Double, @NonNull acc, @NonNull R> operation
)

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

final void
forEach(@NonNull Function1<@NonNull DoubleUnit> block)

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

final void
forEachIndexed(
    @NonNull Function2<@NonNull Integer, @NonNull DoubleUnit> block
)

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

final void
forEachReversed(@NonNull Function1<@NonNull DoubleUnit> block)

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

final void
forEachReversedIndexed(
    @NonNull Function2<@NonNull Integer, @NonNull DoubleUnit> block
)

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

final double
get(@IntRange(from = 0) int index)

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

final @NonNull IntRange

Returns an IntRange of the valid indices for this DoubleList.

final @IntRange(from = -1) int

Returns the last valid index in the DoubleList.

final @IntRange(from = 0) int

The number of elements in the DoubleList.

int

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

final int
indexOf(double element)

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

final int
indexOfFirst(
    @NonNull Function1<@NonNull Double, @NonNull Boolean> predicate
)

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

final int
indexOfLast(@NonNull Function1<@NonNull Double, @NonNull Boolean> predicate)

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

final boolean

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

final boolean

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

final @NonNull String
joinToString(
    @NonNull CharSequence separator,
  &