libgdx API

com.badlogic.gdx.utils
Class DelayedRemovalArray<T>

java.lang.Object
  extended by com.badlogic.gdx.utils.Array<T>
      extended by com.badlogic.gdx.utils.DelayedRemovalArray<T>
All Implemented Interfaces:
java.lang.Iterable<T>

public class DelayedRemovalArray<T>
extends Array<T>

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), 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..

Author:
Nathan Sweet

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
DelayedRemovalArray()
           
DelayedRemovalArray(Array array)
           
DelayedRemovalArray(boolean ordered, int capacity)
           
DelayedRemovalArray(boolean ordered, int capacity, java.lang.Class<T> arrayType)
           
DelayedRemovalArray(boolean ordered, T[] array)
           
DelayedRemovalArray(java.lang.Class<T> arrayType)
           
DelayedRemovalArray(int capacity)
           
DelayedRemovalArray(T[] array)
           
 
Method Summary
 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.
 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

DelayedRemovalArray

public DelayedRemovalArray()

DelayedRemovalArray

public DelayedRemovalArray(Array array)

DelayedRemovalArray

public DelayedRemovalArray(boolean ordered,
                           int capacity,
                           java.lang.Class<T> arrayType)

DelayedRemovalArray

public DelayedRemovalArray(boolean ordered,
                           int capacity)

DelayedRemovalArray

public DelayedRemovalArray(boolean ordered,
                           T[] array)

DelayedRemovalArray

public DelayedRemovalArray(java.lang.Class<T> arrayType)

DelayedRemovalArray

public DelayedRemovalArray(int capacity)

DelayedRemovalArray

public DelayedRemovalArray(T[] array)
Method Detail

begin

public void begin()

end

public void end()

removeValue

public boolean removeValue(T value,
                           boolean identity)
Overrides:
removeValue in class Array<T>

removeIndex

public T removeIndex(int index)
Description copied from class: Array
Removes and returns the item at the specified index.

Overrides:
removeIndex in class Array<T>

set

public void set(int index,
                T value)
Overrides:
set in class Array<T>

insert

public void insert(int index,
                   T value)
Overrides:
insert in class Array<T>

swap

public void swap(int first,
                 int second)
Overrides:
swap in class Array<T>

pop

public T pop()
Description copied from class: Array
Removes and returns the last item.

Overrides:
pop in class Array<T>

clear

public void clear()
Overrides:
clear in class Array<T>

sort

public void sort()
Description copied from class: Array
Sorts this array. The array elements must implement Comparable. This method is not thread safe (uses Sort.instance()).

Overrides:
sort in class Array<T>

sort

public void sort(java.util.Comparator<T> comparator)
Description copied from class: Array
Sorts the array. This method is not thread safe (uses Sort.instance()).

Overrides:
sort in class Array<T>

reverse

public void reverse()
Overrides:
reverse in class Array<T>

shuffle

public void shuffle()
Overrides:
shuffle in class Array<T>

truncate

public void truncate(int newSize)
Description copied from class: Array
Reduces the size of the array to the specified size. If the array is already smaller than the specified size, no action is taken.

Overrides:
truncate in class Array<T>

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)