MutableLongList
public final class MutableLongList extends LongList
MutableLongList is a MutableList-like collection for Long values. It allows storing and retrieving the elements without boxing. Immutable access is available through its base class LongList, 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 |
|---|
MutableLongList(int initialCapacity)Creates a |
Public methods |
|
|---|---|
final boolean |
add(long 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(long element)
|
final void |
minusAssign(@NonNull long[] elements)Removes all |
final void |
minusAssign(@NonNull LongList elements)Removes all |
final void |
plusAssign(long element)
|
final void |
plusAssign(@NonNull long[] elements)Adds all |
final void |
plusAssign(@NonNull LongList elements)Adds all |
final boolean |
remove(long element)Removes |
final boolean |
Removes all |
final boolean |
Removes all |
final long |
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 long |
|
final void |
sort()Sorts the |
final void |
Sorts the |
final void |
trim(int minCapacity)Reduces the internal storage. |
Inherited methods |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
MutableLongList
public MutableLongList(int initialCapacity)
Creates a MutableLongList with a capacity of initialCapacity.
Public methods
add
public final boolean add(long element)
Adds element to the MutableLongList and returns true.
add
public final void add(@IntRange(from = 0) int index, long element)
Adds element to the MutableLongList at the given index, shifting over any elements at index and after, if any.
addAll
public final boolean addAll(@NonNull long[] elements)
Adds all elements to the end of the MutableLongList and returns true if the MutableLongList was changed or false if elements was empty.
addAll
public final boolean addAll(@NonNull LongList elements)
Adds all elements to the end of the MutableLongList and returns true if the MutableLongList was changed or false if elements was empty.
addAll
public final boolean addAll(@IntRange(from = 0) int index, @NonNull long[] elements)
Adds all elements to the MutableLongList 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 LongList elements)
Adds all elements to the MutableLongList 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 MutableLongList. 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 MutableLongList.
| See also | |
|---|---|
trim |
getCapacity
public final int getCapacity()
Returns the total number of elements that can be held before the MutableLongList must grow.
| See also | |
|---|---|
ensureCapacity |
minusAssign
public final void minusAssign(long element)
remove from the MutableLongList
minusAssign
public final void minusAssign(@NonNull long[] elements)
Removes all elements from the MutableLongList.
minusAssign
public final void minusAssign(@NonNull LongList elements)
Removes all elements from the MutableLongList.
plusAssign
public final void plusAssign(@NonNull long[] elements)
Adds all elements to the end of the MutableLongList.
plusAssign
public final void plusAssign(@NonNull LongList elements)
Adds all elements to the end of the MutableLongList.
remove
public final boolean remove(long element)
Removes element from the MutableLongList. If element was in the MutableLongList and was removed, true will be returned, or false will be returned if the element was not found.
removeAll
public final boolean removeAll(@NonNull long[] elements)
Removes all elements from the MutableLongList and returns true if anything was removed.
removeAll
public final boolean removeAll(@NonNull LongList elements)
Removes all elements from the MutableLongList and returns true if anything was removed.
removeAt
public final long 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 long[] elements)
Keeps only elements in the MutableLongList and removes all other values.
| Returns | |
|---|---|
boolean |
|
retainAll
public final boolean retainAll(@NonNull LongList elements)
Keeps only elements in the MutableLongList and removes all other values.
| Returns | |
|---|---|
boolean |
|
set
public final long set(@IntRange(from = 0) int index, long element)
Sets the value at index to element.
| Returns | |
|---|---|
long |
the previous value set at |
sortDescending
public final void sortDescending()
Sorts the MutableLongList 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 |