• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ArrayReflection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.badlogic.gdx.utils.reflect.ArrayReflection的典型用法代码示例。如果您正苦于以下问题:Java ArrayReflection类的具体用法?Java ArrayReflection怎么用?Java ArrayReflection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ArrayReflection类属于com.badlogic.gdx.utils.reflect包,在下文中一共展示了ArrayReflection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


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


示例17: create

import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
@Override
public void create () {
	font = new BitmapFont();
	batch = new SpriteBatch();

	try {
		Vector2 fromDefaultConstructor = ClassReflection.newInstance(Vector2.class);
		println("From default constructor: " + fromDefaultConstructor);

		Method mSet = ClassReflection.getMethod(Vector2.class, "set", float.class, float.class);
		mSet.invoke(fromDefaultConstructor, 10, 11);
		println("Set to 10/11: " + fromDefaultConstructor);

		Constructor copyConstroctor = ClassReflection.getConstructor(Vector2.class, Vector2.class);
		Vector2 fromCopyConstructor = (Vector2)copyConstroctor.newInstance(fromDefaultConstructor);
		println("From copy constructor: " + fromCopyConstructor);

		Method mMul = ClassReflection.getMethod(Vector2.class, "scl", float.class);
		println("Multiplied by 2; " + mMul.invoke(fromCopyConstructor, 2));

		Method mNor = ClassReflection.getMethod(Vector2.class, "nor");
		println("Normalized: " + mNor.invoke(fromCopyConstructor));

		Vector2 fieldCopy = new Vector2();
		Field fx = ClassReflection.getField(Vector2.class, "x");
		Field fy = ClassReflection.getField(Vector2.class, "y");
		fx.set(fieldCopy, fx.get(fromCopyConstructor));
		fy.set(fieldCopy, fy.get(fromCopyConstructor));
		println("Copied field by field: " + fieldCopy);

		Json json = new Json();
		String jsonString = json.toJson(fromCopyConstructor);
		Vector2 fromJson = json.fromJson(Vector2.class, jsonString);
		println("JSON serialized: " + jsonString);
		println("JSON deserialized: " + fromJson);
		fromJson.x += 1;
		fromJson.y += 1;
		println("JSON deserialized + 1/1: " + fromJson);

		Object array = ArrayReflection.newInstance(int.class, 5);
		ArrayReflection.set(array, 0, 42);
		println("Array int: length=" + ArrayReflection.getLength(array) + ", access=" + ArrayReflection.get(array, 0));

		array = ArrayReflection.newInstance(String.class, 5);
		ArrayReflection.set(array, 0, "test string");
		println("Array String: length=" + ArrayReflection.getLength(array) + ", access=" + ArrayReflection.get(array, 0));
	} catch (Exception e) {
		message = "FAILED: " + e.getMessage() + "\n";
		message += e.getClass();
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:52,代码来源:ReflectionTest.java


示例18: 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:kovertopz,项目名称:libGDX-LWJGL-Audio,代码行数:6,代码来源:Array.java


示例19: ArrayIterable

import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
public ArrayIterable(Object anArray) {
	this.arrayLength = ArrayReflection.getLength(anArray);
	this.innerArray = anArray;
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:5,代码来源:Operation.java


示例20: next

import com.badlogic.gdx.utils.reflect.ArrayReflection; //导入依赖的package包/类
@Override
public Expression next() {
	currentElement.value = ArrayReflection.get(innerArray,
			arrayPosition++);
	return currentElement;
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:7,代码来源:Operation.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ConnectorState类代码示例发布时间:2022-05-22
下一篇:
Java ValidationMessageAcceptor类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap