APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.utils

public Class DelayedRemovalArray<T>

extends Array<T>
Class Inheritance
Imports
java.util.Comparator

An array that queues removal during iteration until the iteration has completed. Queues any removals done after 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.

Author
Nathan Sweet

Field Summary

Modifier and TypeField and Description
private int
private int
private IntArray
Inherited from com.badlogic.gdx.utils.Array:
itemsorderedsize

Constructor Summary

AccessConstructor and Description
public
public
public
DelayedRemovalArray(boolean ordered, int capacity, ArraySupplier<T[]> arraySupplier)

public
DelayedRemovalArray(boolean ordered, int capacity, Class<T> arrayType)
Deprecated

public
DelayedRemovalArray(boolean ordered, int capacity)

public
DelayedRemovalArray(boolean ordered, T[] array, int startIndex, int count)

public
DelayedRemovalArray(ArraySupplier<T[]> arraySupplier)

public
DelayedRemovalArray(Class<T> arrayType)
Deprecated

public
DelayedRemovalArray(int capacity)

public

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
end()

public void
insert(int index, T value)

Overrides com.badlogic.gdx.utils.Array.insert.

public void
insertRange(int index, int count)

Overrides com.badlogic.gdx.utils.Array.insertRange.

Inserts the specified number of items at the specified index.

public T
pop()

Overrides com.badlogic.gdx.utils.Array.pop.

Removes and returns the last item.

private void
remove(int index)

public T
removeIndex(int index)

Overrides com.badlogic.gdx.utils.Array.removeIndex.

Removes and returns the item at the specified index.

public void
removeRange(int start, int end)

Overrides com.badlogic.gdx.utils.Array.removeRange.

Removes the items between the specified indices, inclusive.

public boolean
removeValue(T value, boolean identity)

Overrides com.badlogic.gdx.utils.Array.removeValue.

Removes the first instance of the specified value in the array.

public int
replaceAll(T value, boolean identity, T replacement)

Overrides com.badlogic.gdx.utils.Array.replaceAll.

Returns the number of replacements done.

public boolean
replaceFirst(T value, boolean identity, T replacement)

Overrides com.badlogic.gdx.utils.Array.replaceFirst.

Returns true if the specified value was replaced successfully with the replacement

public void
public void
set(int index, T value)

Overrides com.badlogic.gdx.utils.Array.set.

public T[]
setSize(int newSize)

Overrides com.badlogic.gdx.utils.Array.setSize.

Sets the array size, leaving any values beyond the current size null.

public void
public void
sort()

Overrides com.badlogic.gdx.utils.Array.sort.

Sorts this array.

public void
sort(Comparator<? super T> comparator)

Overrides com.badlogic.gdx.utils.Array.sort.

Sorts the array.

public void
swap(int first, int second)

Overrides com.badlogic.gdx.utils.Array.swap.

public void
truncate(int newSize)

Overrides com.badlogic.gdx.utils.Array.truncate.

Reduces the size of the array to the specified size.

public static <T> DelayedRemovalArray<T>
Inherited from com.badlogic.gdx.utils.Array:
addaddaddaddaddAlladdAlladdAlladdAllcontainscontainsAllcontainsAnyensureCapacityequalsequalsIdentityfirstgethashCodeindexOfisEmptyiteratorlastIndexOfnotEmptyofofofofpeekrandomremoveAllresizeselectselectRankedselectRankedIndexshrinktoArraytoArraytoArraytoStringtoString

Field Detail

clearback to summary
private int clear
iteratingback to summary
private int iterating
removeback to summary
private IntArray remove

Constructor Detail

DelayedRemovalArrayback to summary
public DelayedRemovalArray()
DelayedRemovalArrayback to summary
public DelayedRemovalArray(Array<T> array)
DelayedRemovalArrayback to summary
public DelayedRemovalArray(boolean ordered, int capacity, ArraySupplier<T[]> arraySupplier)
DelayedRemovalArrayback to summary
public DelayedRemovalArray(boolean ordered, int capacity, Class<T> arrayType)

Deprecated

Annotations
@Deprecated
DelayedRemovalArrayback to summary
public DelayedRemovalArray(boolean ordered, int capacity)
DelayedRemovalArrayback to summary
public DelayedRemovalArray(boolean ordered, T[] array, int startIndex, int count)
DelayedRemovalArrayback to summary
public DelayedRemovalArray(ArraySupplier<T[]> arraySupplier)
DelayedRemovalArrayback to summary
public DelayedRemovalArray(Class<T> arrayType)

Deprecated

Annotations
@Deprecated
DelayedRemovalArrayback to summary
public DelayedRemovalArray(int capacity)
DelayedRemovalArrayback to summary
public DelayedRemovalArray(T[] array)

Method Detail

beginback to summary
public void begin()
clearback to summary
public void clear()

Overrides com.badlogic.gdx.utils.Array.clear.

endback to summary
public void end()
insertback to summary
public void insert(int index, T value)

Overrides com.badlogic.gdx.utils.Array.insert.

insertRangeback to summary
public void insertRange(int index, int count)

Overrides com.badlogic.gdx.utils.Array.insertRange.

Doc from com.badlogic.gdx.utils.Array.insertRange.

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.

popback to summary
public T pop()

Overrides com.badlogic.gdx.utils.Array.pop.

Doc from com.badlogic.gdx.utils.Array.pop.

Removes and returns the last item.

removeback to summary
private void remove(int index)
removeIndexback to summary
public T removeIndex(int index)

Overrides com.badlogic.gdx.utils.Array.removeIndex.

Doc from com.badlogic.gdx.utils.Array.removeIndex.

Removes and returns the item at the specified index.

removeRangeback to summary
public void removeRange(int start, int end)

Overrides com.badlogic.gdx.utils.Array.removeRange.

Doc from com.badlogic.gdx.utils.Array.removeRange.

Removes the items between the specified indices, inclusive.

removeValueback to summary
public boolean removeValue(T value, boolean identity)

Overrides com.badlogic.gdx.utils.Array.removeValue.

Doc from com.badlogic.gdx.utils.Array.removeValue.

Removes the first instance of the specified value in the array.

replaceAllback to summary
public int replaceAll(T value, boolean identity, T replacement)

Overrides com.badlogic.gdx.utils.Array.replaceAll.

Doc from com.badlogic.gdx.utils.Array.replaceAll.

Returns the number of replacements done.

replaceFirstback to summary
public boolean replaceFirst(T value, boolean identity, T replacement)

Overrides com.badlogic.gdx.utils.Array.replaceFirst.

Doc from com.badlogic.gdx.utils.Array.replaceFirst.

Returns true if the specified value was replaced successfully with the replacement

reverseback to summary
public void reverse()

Overrides com.badlogic.gdx.utils.Array.reverse.

setback to summary
public void set(int index, T value)

Overrides com.badlogic.gdx.utils.Array.set.

setSizeback to summary
public T[] setSize(int newSize)

Overrides com.badlogic.gdx.utils.Array.setSize.

Doc from com.badlogic.gdx.utils.Array.setSize.

Sets the array size, leaving any values beyond the current size null.

shuffleback to summary
public void shuffle()

Overrides com.badlogic.gdx.utils.Array.shuffle.

sortback to summary
public void sort()

Overrides com.badlogic.gdx.utils.Array.sort.

Doc from com.badlogic.gdx.utils.Array.sort.

Sorts this array. The array elements must implement Comparable. This method is not thread safe (uses Sort#instance()).

sortback to summary
public void sort(Comparator<? super T> comparator)

Overrides com.badlogic.gdx.utils.Array.sort.

Doc from com.badlogic.gdx.utils.Array.sort.

Sorts the array. This method is not thread safe (uses Sort#instance()).

swapback to summary
public void swap(int first, int second)

Overrides com.badlogic.gdx.utils.Array.swap.

truncateback to summary
public void truncate(int newSize)

Overrides com.badlogic.gdx.utils.Array.truncate.

Doc from com.badlogic.gdx.utils.Array.truncate.

Reduces the size of the array to the specified size. If the array is already smaller than the specified size, no action is taken.

withback to summary
public static <T> DelayedRemovalArray<T> with(T... array)

Hides com.badlogic.gdx.utils.Array.with.

See Also
DelayedRemovalArray(Object[])