Example usage for com.badlogic.gdx.utils Array Array

List of usage examples for com.badlogic.gdx.utils Array Array

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils Array Array.

Prototype

public Array(boolean ordered, int capacity, Class arrayType) 

Source Link

Document

Creates a new array with #items of the specified type.

Usage

From source file:com.badlydrawngames.general.Pools.java

License:Apache License

/** Creates an array from a pool, freeing its items if it already exists.
 * @param <T> the type of item allocated in the array.
 * @param array the array of items to (re)create.
 * @param pool the pool that the items are to be allocated from / released to.
 * @param size the array's capacity./*from  ww w .jav  a 2s  .c  o  m*/
 * @return the input array */
@SuppressWarnings("unchecked")
public static <T> Array<T> makeArrayFromPool(Array<T> array, Pool<T> pool, int size) {
    if (array == null) {
        // Do this so that array.items can be used.
        T t = pool.obtain();
        array = new Array<T>(false, size, (Class<T>) t.getClass());
        pool.free(t);
    } else {
        freeArrayToPool(array, pool);
    }
    return array;
}