本文整理汇总了Java中com.badlogic.gdx.utils.reflect.ArrayReflection类的典型用法代码示例。如果您正苦于以下问题:Java ArrayReflection类的具体用法?Java ArrayReflection怎么用?Java ArrayReflection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayReflection类属于com.badlogic.gdx.utils.reflect包,在下文中一共展示了ArrayReflection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reallocateBuffer
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
/** Reallocate a buffer. */
public static <T> T[] reallocateBuffer(Class<T> klass, T[] oldBuffer, int oldCapacity,
int newCapacity) {
assert (newCapacity > oldCapacity);
@SuppressWarnings("unchecked")
T[] newBuffer = (T[]) ArrayReflection.newInstance(klass, newCapacity);
if (oldBuffer != null) {
System.arraycopy(oldBuffer, 0, newBuffer, 0, oldCapacity);
}
for (int i = oldCapacity; i < newCapacity; i++) {
try {
newBuffer[i] = ClassReflection.newInstance(klass);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return newBuffer;
}
示例2: getAll
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
@Override
public <T> T[] getAll(Class<T> clazz) {
Object[] got = gotAll.get(clazz);
if (got != null) {
return (T[]) got;
}
Array<ISystem> matching = cache.getNext();
matching.clear();
for (int i = 0; i < systems.size; i++) {
ISystem system = systems.items[i];
if (clazz.isAssignableFrom(system.getClass())) {
matching.add(system);
}
}
T[] array = (T[]) ArrayReflection.newInstance(clazz, matching.size);
System.arraycopy(matching.items, 0, array, 0, array.length);
gotAll.put(clazz, array);
return array;
}
示例3: resize
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
/** Creates a new backing array with the specified size containing the current items. */
protected T[] resize (int newSize) {
T[] items = this.items;
T[] newItems = (T[])ArrayReflection.newInstance(items.getClass().getComponentType(), newSize);
System.arraycopy(items, 0, newItems, 0, Math.min(size, newItems.length));
this.items = newItems;
return newItems;
}
示例4: resize
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
/** Creates a new backing array with the specified capacity containing the current items.
* @param newCapacity the new capacity */
protected void resize (int newCapacity) {
@SuppressWarnings("unchecked")
T[] newItems = (T[])ArrayReflection.newInstance(items.getClass().getComponentType(), newCapacity);
if (tail > head) {
System.arraycopy(items, head, newItems, 0, size);
} else if (size > 0) { // NOTE: when head == tail the buffer can be empty or full
System.arraycopy(items, head, newItems, 0, items.length - head);
System.arraycopy(items, 0, newItems, items.length - head, tail);
}
head = 0;
tail = size;
items = newItems;
}
示例5: resize
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
protected void resize (int newSize) {
K[] newKeys = (K[])ArrayReflection.newInstance(keys.getClass().getComponentType(), newSize);
System.arraycopy(keys, 0, newKeys, 0, Math.min(size, newKeys.length));
this.keys = newKeys;
V[] newValues = (V[])ArrayReflection.newInstance(values.getClass().getComponentType(), newSize);
System.arraycopy(values, 0, newValues, 0, Math.min(size, newValues.length));
this.values = newValues;
}
示例6: requestParticleBuffer
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
@SuppressWarnings("unchecked")
<T> T[] requestParticleBuffer(Class<T> klass, T[] buffer) {
if (buffer == null) {
buffer = (T[]) ArrayReflection.newInstance(klass, m_internalAllocatedCapacity);
for (int i = 0; i < m_internalAllocatedCapacity; i++) {
try {
buffer[i] = ClassReflection.newInstance(klass);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
return buffer;
}
示例7: resize
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
/**
* Creates a new backing array with the specified size containing the current items.
*
* @param newSize
* @return
*/
protected T[] resize(int newSize) {
T[] items = this.items;
T[] newItems = (T[]) ArrayReflection.newInstance(items.getClass().getComponentType(), newSize);
System.arraycopy(items, 0, newItems, 0, Math.min(size, newItems.length));
this.items = newItems;
return newItems;
}
示例8: resize
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
protected void resize(int newSize) {
K[] newKeys = (K[]) ArrayReflection.newInstance(keys.getClass().getComponentType(), newSize);
System.arraycopy(keys, 0, newKeys, 0, Math.min(size, newKeys.length));
this.keys = newKeys;
V[] newValues = (V[]) ArrayReflection.newInstance(values.getClass().getComponentType(), newSize);
System.arraycopy(values, 0, newValues, 0, Math.min(size, newValues.length));
this.values = newValues;
}
示例9: resize
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
/**
* Creates a new backing array with the specified size containing the
* current items.
*/
protected T[] resize(int newSize) {
T[] items = this.items;
T[] newItems = (T[]) ArrayReflection.newInstance(items.getClass().getComponentType(), newSize);
System.arraycopy(items, 0, newItems, 0, Math.min(size, newItems.length));
this.items = newItems;
return newItems;
}
示例10: evaluate
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
@Override
public Object evaluate(VarsContext context)
throws ExpressionEvaluationException {
// First arg should be the container object
// First argument should always be a collection or similar
Object arg1 = first().evaluate(context);
if (arg1.getClass().isArray()) {
return ArrayReflection.getLength(arg1);
} else if (arg1 instanceof Array) {
Array array = (Array) arg1;
return array.size;
} else if (arg1 instanceof Map) {
Map map = (Map) arg1;
return map.size();
} else if (arg1 instanceof Collection) {
Collection collection = (Collection) arg1;
return collection.size();
} else if (arg1 instanceof Iterable) {
Iterable iterable = (Iterable) arg1;
int i = 0;
for (Object object : iterable) {
i++;
}
return i;
} else {
throw new ExpressionEvaluationException(
"Could not evaluate "
+ getName()
+ ". Revise the first argument is a collection, array, iterable or map.",
this);
}
}
示例11: Array
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
/** Creates a new array with {@link #items} of the specified type.
* @param ordered If false, methods that remove elements may change the order of other elements in the array, which avoids a
* memory copy.
* @param capacity Any elements added beyond this will cause the backing array to be grown. */
public Array (boolean ordered, int capacity, Class arrayType) {
this.ordered = ordered;
items = (T[])ArrayReflection.newInstance(arrayType, capacity);
}
示例12: toArray
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
public <V> V[] toArray (Class type) {
V[] result = (V[])ArrayReflection.newInstance(type, size);
System.arraycopy(items, 0, result, 0, size);
return result;
}
示例13: getArray
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Type[] getArray(final int size) {
return (Type[]) ArrayReflection.newInstance(arrayType, size);
}
示例14: ObjectChannel
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
public ObjectChannel (int id, int strideSize, int size, Class<T> type) {
super(id, ArrayReflection.newInstance(type, size*strideSize), strideSize);
componentType = type;
this.data = (T[]) super.data;
}
示例15: setCapacity
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
@Override
public void setCapacity (int requiredCapacity) {
T[] newData = (T[]) ArrayReflection.newInstance(componentType, strideSize * requiredCapacity);
System.arraycopy(data, 0, newData, 0, Math.min(data.length, newData.length));
super.data = data = newData;
}