MutableFloatList
public final class MutableFloatList extends FloatList
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(int initialCapacity)Creates a |
Public methods |
|
|---|---|
final boolean |
add(float element)Adds |
final void |
Adds |
final boolean |
Adds all |
final boolean |
Adds all |
final boolean |
Adds all |
final boolean |
Adds all |
final void |
clear()Removes all elements in the |
final void |
ensureCapacity(int capacity)Ensures that there is enough space to store |
final int |
Returns the total number of elements that can be held before the |
final void |
minusAssign(float element)
|
final void |
minusAssign(@NonNull float[] elements)Removes all |
final void |
minusAssign(@NonNull FloatList elements)Removes all |
final void |
plusAssign(float element)
|
final void |
plusAssign(@NonNull float[] elements)Adds all |
final void |
plusAssign(@NonNull FloatList elements)Adds all |
final boolean |
remove(float element)Removes |
final boolean |
Removes all |
final boolean |
Removes all |
final float |
Removes the element at the given |
final void |
removeRange(@IntRange(from = 0) int start, @IntRange(from = 0) int end)Removes items from index |
final boolean |
Keeps only |
final boolean |
Keeps only |
final float |
|
final void |
sort()Sorts the |
final void |
Sorts the |
final void |
trim(int minCapacity)Reduces the internal storage. |
Inherited methods |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
MutableFloatList
public MutableFloatList(int initialCapacity)
Creates a MutableFloatList with a capacity of initialCapacity.
Public methods
add
public final boolean add(float element)
Adds element to the MutableFloatList and returns true.
add
public final void add(@IntRange(from = 0) int index, float element)
Adds element to the MutableFloatList at the given index, shifting over any elements at index and after, if any.
addAll
public final boolean addAll(@NonNull float[] elements)
Adds all elements to the end of the MutableFloatList and returns true if the MutableFloatList was changed or false if elements was empty.
addAll
public final boolean addAll(@NonNull FloatList elements)
Adds all elements to the end of the MutableFloatList and returns true if the MutableFloatList was changed or false if elements was empty.
addAll
public final boolean addAll(@IntRange(from = 0) int index, @NonNull float[] elements)
Adds all elements to the MutableFloatList at the given index, shifting over any elements at index and after, if any.
| Returns | |
|---|---|
boolean |
|
addAll
public final boolean addAll(@IntRange(from = 0) int index, @NonNull FloatList elements)
Adds all elements to the MutableFloatList at the given index, shifting over any elements at index and after, if any.
| Returns | |
|---|---|
boolean |
|
clear
public final void clear()
Removes all elements in the MutableFloatList. The storage isn't released.
| See also | |
|---|---|
trim |
ensureCapacity
public final void ensureCapacity(int capacity)
Ensures that there is enough space to store capacity elements in the MutableFloatList.
| See also | |
|---|---|
trim |
getCapacity
public final int getCapacity()
Returns the total number of elements that can be held before the MutableFloatList must grow.
| See also | |
|---|---|
ensureCapacity |
minusAssign
public final void minusAssign(float element)
remove from the MutableFloatList
minusAssign
public final void minusAssign(@NonNull float[] elements)
Removes all elements from the MutableFloatList.
minusAssign
public final void minusAssign(@NonNull FloatList elements)
Removes all elements from the MutableFloatList.
plusAssign
public final void plusAssign(@NonNull float[] elements)
Adds all elements to the end of the MutableFloatList.
plusAssign
public final void plusAssign(@NonNull FloatList elements)
Adds all elements to the end of the MutableFloatList.
remove
public final boolean remove(float element)
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
public final boolean removeAll(@NonNull float[] elements)
Removes all elements from the MutableFloatList and returns true if anything was removed.
removeAll
public final boolean removeAll(@NonNull FloatList elements)
Removes all elements from the MutableFloatList and returns true if anything was removed.
removeAt
public final float removeAt(@IntRange(from = 0) int index)
Removes the element at the given index and returns it.
removeRange
public final void removeRange(@IntRange(from = 0) int start, @IntRange(from = 0) int end)
Removes items from index start (inclusive) to end (exclusive).
retainAll
public final boolean retainAll(@NonNull float[] elements)
Keeps only elements in the MutableFloatList and removes all other values.
| Returns | |
|---|---|
boolean |
|
retainAll
public final boolean retainAll(@NonNull FloatList elements)
Keeps only elements in the MutableFloatList and removes all other values.
| Returns | |
|---|---|
boolean |
|
set
public final float set(@IntRange(from = 0) int index, float element)
Sets the value at index to element.
| Returns | |
|---|---|
float |
the previous value set at |
sort
public final void sort()
Sorts the MutableFloatList elements in ascending order.
sortDescending
public final void sortDescending()
Sorts the MutableFloatList elements in descending order.
trim
public final void trim(int minCapacity)
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 |