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)
, and add methods are allowed.
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) |
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) |
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) |
public 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)
Array
removeValue
in class Array<T>
identity
- If true, == comparison will be used. If false, .equals() comparison will be used.public T removeIndex(int index)
Array
removeIndex
in class Array<T>
public void removeRange(int start, int end)
Array
removeRange
in class Array<T>
public void sort()
Array
Comparable
. This method is not thread safe (uses
Sort.instance()
).public void sort(Comparator<? super T> comparator)
Array
Sort.instance()
).public void truncate(int newSize)
Array
public static <T> DelayedRemovalArray<T> with(T... array)
DelayedRemovalArray(Object[])
Copyright © 2014. All Rights Reserved.