begin() between indexes
0 and size at the time begin was called will not be modified until end() is called. If modification of the
SnapshotArray occurs between begin/end, the backing array is copied prior to the modification, ensuring that the backing array
that was returned by begin() is unaffected. To avoid allocation, an attempt is made to reuse any extra array created
as a result of this copy on subsequent copies.
Note that SnapshotArray is not for thread safety, only for modification during iteration.
It is suggested iteration be done in this specific way:
SnapshotArray- array = new SnapshotArray(); // ... Object[] items = array.begin(); for (int i = 0, n = array.size; i < n; i++) { Item item = (Item)items[i]; // ... } array.end();
| Modifier and Type | Field and Description |
|---|---|
| private T[] | |
| private T[] | |
| private int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | |
| public | |
| public | |
| public | |
| public | |
| public | |
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public T[] | |
| public void | |
| public void | |
| public void | |
| public void | insertRange(int index, int count)
Overrides com. Inserts the specified number of items at the specified index. |
| private void | |
| public T | |
| public boolean | removeAll(Array<? extends T> array, boolean identity)
Overrides com. Removes from this array the first instance of each element contained in the specified array. |
| public T | removeIndex(int index)
Overrides com. Removes and returns the item at the specified index. |
| public void | removeRange(int start, int end)
Overrides com. Removes the items between the specified indices, inclusive. |
| public boolean | removeValue(T value, boolean identity)
Overrides com. Removes the first instance of the specified value in the array. |
| public int | replaceAll(T value, boolean identity, T replacement)
Overrides com. Returns the number of replacements done. |
| public boolean | replaceFirst(T value, boolean identity, T replacement)
Overrides com. Returns true if the specified value was replaced successfully with the replacement |
| public void | |
| public void | |
| public T[] | setSize(int newSize)
Overrides com. Sets the array size, leaving any values beyond the current size null. |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | truncate(int newSize)
Overrides com. Reduces the size of the array to the specified size. |
| public static <T> SnapshotArray |
| recycled | back to summary |
|---|---|
| private T[] recycled | |
| snapshot | back to summary |
|---|---|
| private T[] snapshot | |
| snapshots | back to summary |
|---|---|
| private int snapshots | |
| SnapshotArray | back to summary |
|---|---|
| public SnapshotArray() | |
| SnapshotArray | back to summary |
|---|---|
| public SnapshotArray(Array<T> array) | |
| SnapshotArray | back to summary |
|---|---|
| public SnapshotArray(boolean ordered, int capacity, ArraySupplier<T[]> arraySupplier) | |
| SnapshotArray | back to summary |
|---|---|
| public SnapshotArray(boolean ordered, int capacity, Class<T> arrayType)
Deprecated
| |
| SnapshotArray | back to summary |
|---|---|
| public SnapshotArray(boolean ordered, int capacity) | |
| SnapshotArray | back to summary |
|---|---|
| public SnapshotArray(boolean ordered, T[] array, int startIndex, int count) | |
| SnapshotArray | back to summary |
|---|---|
| public SnapshotArray(ArraySupplier<T[]> arraySupplier) | |
| SnapshotArray | back to summary |
|---|---|
| public SnapshotArray(Class<T> arrayType)
Deprecated
| |
| SnapshotArray | back to summary |
|---|---|
| public SnapshotArray(int capacity) | |
| SnapshotArray | back to summary |
|---|---|
| public SnapshotArray(T[] array) | |
| begin | back to summary |
|---|---|
| public T[] begin() Returns the backing array, which is guaranteed to not be modified before | |
| clear | back to summary |
|---|---|
| public void clear() Overrides com. | |
| end | back to summary |
|---|---|
| public void end() Releases the guarantee that the array returned by | |
| insert | back to summary |
|---|---|
| public void insert(int index, T value) Overrides com. | |
| insertRange | back to summary |
|---|---|
| public void insertRange(int index, int count) Overrides com. Doc from com. Inserts the specified number of items at the specified index. The new items will have values equal to the values at those indices before the insertion. | |
| modified | back to summary |
|---|---|
| private void modified() | |
| pop | back to summary |
|---|---|
| public T pop() Overrides com. Doc from com. Removes and returns the last item. | |
| removeAll | back to summary |
|---|---|
| public boolean removeAll(Array<? extends T> array, boolean identity) Overrides com. Doc from com. Removes from this array the first instance of each element contained in the specified array. | |
| removeIndex | back to summary |
|---|---|
| public T removeIndex(int index) Overrides com. Doc from com. Removes and returns the item at the specified index. | |
| removeRange | back to summary |
|---|---|
| public void removeRange(int start, int end) Overrides com. Doc from com. Removes the items between the specified indices, inclusive. | |
| removeValue | back to summary |
|---|---|
| public boolean removeValue(T value, boolean identity) Overrides com. Doc from com. Removes the first instance of the specified value in the array. | |
| replaceAll | back to summary |
|---|---|
| public int replaceAll(T value, boolean identity, T replacement) Overrides com. Doc from com. Returns the number of replacements done. | |
| replaceFirst | back to summary |
|---|---|
| public boolean replaceFirst(T value, boolean identity, T replacement) Overrides com. Doc from com. Returns true if the specified value was replaced successfully with the replacement | |
| reverse | back to summary |
|---|---|
| public void reverse() Overrides com. | |
| set | back to summary |
|---|---|
| public void set(int index, T value) Overrides com. | |
| setSize | back to summary |
|---|---|
| public T[] setSize(int newSize) Overrides com. Doc from com. Sets the array size, leaving any values beyond the current size null. | |
| shuffle | back to summary |
|---|---|
| public void shuffle() Overrides com. | |
| sort | back to summary |
|---|---|
| public void sort() Overrides com. Doc from com. Sorts this array. The array elements must implement | |
| sort | back to summary |
|---|---|
| public void sort(Comparator<? super T> comparator) Overrides com. Doc from com. Sorts the array. This method is not thread safe (uses | |
| swap | back to summary |
|---|---|
| public void swap(int first, int second) Overrides com. | |
| truncate | back to summary |
|---|---|
| public void truncate(int newSize) Overrides com. Doc from com. Reduces the size of the array to the specified size. If the array is already smaller than the specified size, no action is taken. | |
| with | back to summary |
|---|---|
| public static <T> SnapshotArray Hides com.
| |