当前位置: 首页>>代码示例>>Java>>正文


Java ArrayReflection类代码示例

本文整理汇总了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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:19,代码来源:BufferUtils.java

示例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;
}
 
开发者ID:0x0ade,项目名称:shadow-engine,代码行数:21,代码来源:DefaultSystemManager.java

示例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;
}
 
开发者ID:Guerra24,项目名称:NanoUI,代码行数:9,代码来源:Array.java

示例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;
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:16,代码来源:CircularBuffer.java

示例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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:10,代码来源:ArrayMap.java

示例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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:15,代码来源:ParticleSystem.java

示例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;
}
 
开发者ID:kovertopz,项目名称:libGDX-LWJGL-Audio,代码行数:14,代码来源:Array.java

示例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;
}
 
开发者ID:chbachman,项目名称:ModularArmour,代码行数:10,代码来源:ArrayMap.java

示例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;
}
 
开发者ID:chbachman,项目名称:ModularArmour,代码行数:12,代码来源:Array.java

示例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);
	}

}
 
开发者ID:e-ucm,项目名称:ead,代码行数:36,代码来源:CollectionSize.java

示例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);
}
 
开发者ID:Guerra24,项目名称:NanoUI,代码行数:9,代码来源:Array.java

示例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;
}
 
开发者ID:Guerra24,项目名称:NanoUI,代码行数:6,代码来源:Array.java

示例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);
}
 
开发者ID:czyzby,项目名称:gdx-lml,代码行数:6,代码来源:ReflectionArrayProvider.java

示例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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:6,代码来源:ParallelArray.java

示例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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:7,代码来源:ParallelArray.java


注:本文中的com.badlogic.gdx.utils.reflect.ArrayReflection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。