public class DelayedRemovalArray<T> extends Array<T>
begin() is called to occur once end() is called. This can allow code out of your control to remove items
without affecting iteration. Between begin and end, most mutator methods will throw IllegalStateException. Only
removeIndex(int), removeValue(Object, boolean), removeRange(int, int), clear(), and add
methods are allowed.
Note that DelayedRemovalArray is not for thread safety, only for removal during iteration.
Code using this class must not rely on items being removed immediately. Consider using SnapshotArray if this is a
problem.
Array.ArrayIterable<T>, Array.ArrayIterator<T>| Constructor and Description |
|---|
DelayedRemovalArray() |
DelayedRemovalArray(Array array) |
DelayedRemovalArray(boolean ordered,
int capacity) |
DelayedRemovalArray(boolean ordered,
int capacity,
Class arrayType) |
DelayedRemovalArray(boolean ordered,
T[] array,
int startIndex,
int count) |
DelayedRemovalArray(Class arrayType) |
DelayedRemovalArray(int capacity) |
DelayedRemovalArray(T[] array) |
| Modifier and Type | Method and Description |
|---|---|
void |
begin() |
void |
clear() |
void |
end() |
void |
insert(int index,
T value) |
void |
insertRange(int index,
int count)
Inserts the specified number of items at the specified index.
|
T |
pop()
Removes and returns the last item.
|
T |
removeIndex(int index)
Removes and returns the item at the specified index.
|
void |
removeRange(int start,
int end)
Removes the items between the specified indices, inclusive.
|
boolean |
removeValue(T value,
boolean identity)
Removes the first instance of the specified value in the array.
|
void |
reverse() |
void |
set(int index,
T value) |
T[] |
setSize(int newSize)
Sets the array size, leaving any values beyond the current size null.
|
void |
shuffle() |
void |
sort()
Sorts this array.
|
void |
sort(Comparator<? super T> comparator)
Sorts the array.
|
void |
swap(int first,
int second) |
void |
truncate(int newSize)
Reduces the size of the array to the specified size.
|
static <T> DelayedRemovalArray<T> |
with(T... array) |
add, add, add, add, addAll, addAll, addAll, addAll, contains, containsAll, containsAny, ensureCapacity, equals, equalsIdentity, first, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, notEmpty, of, of, peek, random, removeAll, select, selectRanked, selectRankedIndex, shrink, toArray, toArray, toString, toStringforEach, spliteratorpublic DelayedRemovalArray()
public DelayedRemovalArray(Array array)
public DelayedRemovalArray(boolean ordered,
int capacity,
Class arrayType)
public DelayedRemovalArray(boolean ordered,
int capacity)
public DelayedRemovalArray(boolean ordered,
T[] array,
int startIndex,
int count)
public DelayedRemovalArray(Class arrayType)
public DelayedRemovalArray(int capacity)
public DelayedRemovalArray(T[] array)
public void begin()
public void end()
public boolean removeValue(T value, boolean identity)
ArrayremoveValue in class Array<T>value - May be null.identity - If true, == comparison will be used. If false, .equals() comparison will be used.public T removeIndex(int index)
ArrayremoveIndex in class Array<T>public void removeRange(int start,
int end)
ArrayremoveRange in class Array<T>public void insertRange(int index,
int count)
ArrayinsertRange in class Array<T>public void sort()
ArrayComparable. This method is not thread safe (uses
Sort.instance()).public void sort(Comparator<? super T> comparator)
ArraySort.instance()).public void truncate(int newSize)
Arraypublic T[] setSize(int newSize)
ArraysetSize in class Array<T>Array.itemspublic static <T> DelayedRemovalArray<T> with(T... array)
DelayedRemovalArray(Object[])Copyright © 2021. All rights reserved.