|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.utils.Array<T>
com.badlogic.gdx.utils.SnapshotArray<T>
public class SnapshotArray<T>
Guarantees that array entries provided by begin()
between indexes 0 and Array.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.
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++) { Object item = items[i]; // ... } array.end();
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.badlogic.gdx.utils.Array |
---|
Array.ArrayIterable<T>, Array.ArrayIterator<T> |
Field Summary |
---|
Fields inherited from class com.badlogic.gdx.utils.Array |
---|
items, ordered, size |
Constructor Summary | |
---|---|
SnapshotArray()
|
|
SnapshotArray(Array array)
|
|
SnapshotArray(boolean ordered,
int capacity)
|
|
SnapshotArray(boolean ordered,
int capacity,
java.lang.Class<T> arrayType)
|
|
SnapshotArray(boolean ordered,
T[] array)
|
|
SnapshotArray(java.lang.Class<T> arrayType)
|
|
SnapshotArray(int capacity)
|
|
SnapshotArray(T[] array)
|
Method Summary | |
---|---|
T[] |
begin()
Returns the backing array, which is guaranteed to not be modified before end() . |
void |
clear()
|
void |
end()
Releases the guarantee that the array returned by begin() won't be modified. |
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. |
boolean |
removeValue(T value,
boolean identity)
|
void |
reverse()
|
void |
set(int index,
T value)
|
void |
shuffle()
|
void |
sort()
Sorts this array. |
void |
sort(java.util.Comparator<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. |
Methods inherited from class com.badlogic.gdx.utils.Array |
---|
add, addAll, addAll, addAll, addAll, contains, ensureCapacity, equals, first, get, indexOf, iterator, lastIndexOf, peek, random, removeAll, resize, shrink, toArray, toArray, toString, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SnapshotArray()
public SnapshotArray(Array array)
public SnapshotArray(boolean ordered, int capacity, java.lang.Class<T> arrayType)
public SnapshotArray(boolean ordered, int capacity)
public SnapshotArray(boolean ordered, T[] array)
public SnapshotArray(java.lang.Class<T> arrayType)
public SnapshotArray(int capacity)
public SnapshotArray(T[] array)
Method Detail |
---|
public T[] begin()
end()
.
public void end()
begin()
won't be modified.
public void set(int index, T value)
set
in class Array<T>
public void insert(int index, T value)
insert
in class Array<T>
public void swap(int first, int second)
swap
in class Array<T>
public boolean removeValue(T value, boolean identity)
removeValue
in class Array<T>
public T removeIndex(int index)
Array
removeIndex
in class Array<T>
public T pop()
Array
pop
in class Array<T>
public void clear()
clear
in class Array<T>
public void sort()
Array
Comparable
. This method is not thread safe (uses
Sort.instance()
).
sort
in class Array<T>
public void sort(java.util.Comparator<T> comparator)
Array
Sort.instance()
).
sort
in class Array<T>
public void reverse()
reverse
in class Array<T>
public void shuffle()
shuffle
in class Array<T>
public void truncate(int newSize)
Array
truncate
in class Array<T>
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |