本文整理汇总了Java中com.badlogic.gdx.utils.reflect.ArrayReflection.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayReflection.newInstance方法的具体用法?Java ArrayReflection.newInstance怎么用?Java ArrayReflection.newInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.reflect.ArrayReflection
的用法示例。
在下文中一共展示了ArrayReflection.newInstance方法的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: 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);
}
示例11: 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;
}
示例12: getArray
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Type[] getArray(final int size) {
return (Type[]) ArrayReflection.newInstance(arrayType, size);
}
示例13: 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;
}
示例14: 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;
}
示例15: ArrayMap
import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入方法依赖的package包/类
/** Creates a new map with {@link #keys} and {@link #values} of the specified type.
* @param ordered If false, methods that remove elements may change the order of other elements in the arrays, which avoids a
* memory copy.
* @param capacity Any elements added beyond this will cause the backing arrays to be grown. */
public ArrayMap (boolean ordered, int capacity, Class keyArrayType, Class valueArrayType) {
this.ordered = ordered;
keys = (K[])ArrayReflection.newInstance(keyArrayType, capacity);
values = (V[])ArrayReflection.newInstance(valueArrayType, capacity);
}