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


Java Bag.add方法代码示例

本文整理汇总了Java中com.artemis.utils.Bag.add方法的典型用法代码示例。如果您正苦于以下问题:Java Bag.add方法的具体用法?Java Bag.add怎么用?Java Bag.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.artemis.utils.Bag的用法示例。


在下文中一共展示了Bag.add方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRelevantListeners

import com.artemis.utils.Bag; //导入方法依赖的package包/类
/** Get listeners that are subscribed to the event. */
protected ImmutableBag<EventListener> getRelevantListeners(Event event) {

    final Bag<EventListener> relevantListeners = new Bag<>();

 // resort listeners when we need to.
 if (sortDirty) {
  sortDirty=false;
  BagUtils.sort(listeners);
 }

 // who needs efficiency! not us!
    for(int i=0, s=listeners.size(); i<s; i++) {
        final EventListener listener = listeners.get(i);
        if ( listener != null ) {
            if ( canHandle(listener, event))
            {
                relevantListeners.add(listener);
            }
        }
    }

 return relevantListeners;
}
 
开发者ID:DaanVanYperen,项目名称:artemis-odb-contrib,代码行数:25,代码来源:BasicEventDispatcher.java

示例2: getEntitiesWithLayer

import com.artemis.utils.Bag; //导入方法依赖的package包/类
public ImmutableBag<Entity> getEntitiesWithLayer (int layerId) {
	Bag<Entity> entities = new Bag<Entity>();

	IntBag bag = subscription.getEntities();
	int[] data = bag.getData();

	for (int i = 0; i < bag.size(); i++) {
		int id = data[i];
		Entity entity = world.getEntity(id);
		Layer layer = layerCm.get(entity);

		if (layer.layerId == layerId)
			entities.add(entity);
	}

	return entities;
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:18,代码来源:LayerManipulator.java

示例3: add

import com.artemis.utils.Bag; //导入方法依赖的package包/类
/**
 * Set the group of the entity.
 * 
 * @param group group to add the entity into.
 * @param e entity to add into the group.
 */
public void add(Entity e, String group) {
	Bag<Entity> entities = entitiesByGroup.get(group);
	if(entities == null) {
		entities = new Bag<Entity>();
		entitiesByGroup.put(group, entities);
	}
	entities.add(e);
	
	Bag<String> groups = groupsByEntity.get(e);
	if(groups == null) {
		groups = new Bag<String>();
		groupsByEntity.put(e, groups);
	}
	groups.add(group);
}
 
开发者ID:lanen,项目名称:mint4j,代码行数:22,代码来源:GroupManager.java

示例4: add

import com.artemis.utils.Bag; //导入方法依赖的package包/类
/**
 * Set the group of the entity.
 * 
 * @param group group to add the entity into.
 * @param e entity to add into the group.
 */
public void add(Entity e, String group) {
	Bag<Entity> entities;
	if (!entitiesByGroup.containsKey(group))
	{
		entities = new Bag<Entity>();
		entitiesByGroup.put(group, entities);
	}
	else
	{
		entities = entitiesByGroup.get(group);
	}
	entities.add(e);
	
	Bag<String> groups;
	if (!groupsByEntity.containsKey(e))
	{
		groups = new Bag<String>();
		groupsByEntity.put(e, groups);	
	}
	else
	{
		groups = groupsByEntity.get(e);
	}
	groups.add(group);
}
 
开发者ID:nhydock,项目名称:gdx-artemis,代码行数:32,代码来源:GroupManager.java

示例5: getExclusiveEntities

import com.artemis.utils.Bag; //导入方法依赖的package包/类
/**
 * Get all entities that only belong to the provided group
 * @param group
 * @return
 */
public ImmutableBag<Entity> getExclusiveEntities(String group) {
	ImmutableBag<Entity> entities = getEntities(group);

	Bag<Entity> bag = new Bag<Entity>();
	//check for collisions
	for (int i = 0; i < entities.size(); i++)
	{
		Entity e = entities.get(i);
		if (getGroups(e).size() == 1){
			bag.add(e);
		}
	}
	
	return bag;
	
}
 
开发者ID:nhydock,项目名称:gdx-artemis,代码行数:22,代码来源:GroupManager.java

示例6: initialize

import com.artemis.utils.Bag; //导入方法依赖的package包/类
@Override
protected void initialize() {
	for (int i = 0; permutations.length > i; i++) {
		Bag<Class<? extends Component>> components = new Bag<Class<? extends Component>>();
		for (int classIndex = 0, s = (int)(rng.nextFloat() * 7) + 3; s > classIndex; classIndex++) {
			components.add(types.get((int)(rng.nextFloat() * types.size())));
		}
		permutations[i] = components;
	}
	
	for (int i = 0; ENTITY_COUNT > i; i++)
		createEntity();
}
 
开发者ID:junkdog,项目名称:entity-system-benchmarks,代码行数:14,代码来源:EntityManglerSystem.java

示例7: register

import com.artemis.utils.Bag; //导入方法依赖的package包/类
@Override
public void register(EventListener listener) {
	if ( listener == null ) throw new NullPointerException("Listener required.");

	// Bind listener to the related event class.
	Bag<EventListener> listenersFor = getListenersFor(listener.getParameterType(), true);
	if ( !listenersFor.contains(listener)) {
		listenersFor.add(listener);
		// the hierarchical cache is now out of date. purrrrrrrrge!
		invalidateHierarchicalCache();
	}

}
 
开发者ID:DaanVanYperen,项目名称:artemis-odb-contrib,代码行数:14,代码来源:FastEventDispatcher.java

示例8: toBag

import com.artemis.utils.Bag; //导入方法依赖的package包/类
public static <E> Bag<E> toBag (Array<E> array) {
	Bag<E> bag = new Bag<E>(array.size);

	for (E element : array)
		bag.add(element);

	return bag;
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:9,代码来源:VisBagUtils.java

示例9: cloneObject

import com.artemis.utils.Bag; //导入方法依赖的package包/类
@Override
protected Bag cloneObject (Bag original, IDeepCloner cloner, Map<Object, Object> clones) {
	Bag bag = new Bag(original.size());

	for (Object obj : original) {
		bag.add(cloner.deepClone(obj, clones));
	}

	return bag;
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:11,代码来源:BagCloner.java

示例10: setPlayer

import com.artemis.utils.Bag; //导入方法依赖的package包/类
public void setPlayer(Entity e, String player) {
	playerByEntity.put(e, player);
	Bag<Entity> entities = entitiesByPlayer.get(player);
	if(entities == null) {
		entities = new Bag<Entity>();
		entitiesByPlayer.put(player, entities);
	}
	entities.add(e);
}
 
开发者ID:lanen,项目名称:mint4j,代码行数:10,代码来源:PlayerManager.java

示例11: setTeam

import com.artemis.utils.Bag; //导入方法依赖的package包/类
public void setTeam(String player, String team) {
	removeFromTeam(player);
	
	teamByPlayer.put(player, team);
	
	Bag<String> players = playersByTeam.get(team);
	if(players == null) {
		players = new Bag<String>();
		playersByTeam.put(team, players);
	}
	players.add(player);
}
 
开发者ID:lanen,项目名称:mint4j,代码行数:13,代码来源:TeamManager.java

示例12: getComponentsFor

import com.artemis.utils.Bag; //导入方法依赖的package包/类
public Bag<Component> getComponentsFor(Entity e, Bag<Component> fillBag) {
	BitSet componentBits = e.getComponentBits();

	for (int i = componentBits.nextSetBit(0); i >= 0; i = componentBits.nextSetBit(i+1)) {
		fillBag.add(componentsByType.get(i).get(e.getId()));
	}
	
	return fillBag;
}
 
开发者ID:lanen,项目名称:mint4j,代码行数:10,代码来源:ComponentManager.java

示例13: getComponentsFor

import com.artemis.utils.Bag; //导入方法依赖的package包/类
public Bag<Component> getComponentsFor(Entity e, Bag<Component> fillBag) {
	Bits componentBits = e.getComponentBits();

	for (int i = componentBits.nextSetBit(0); i >= 0; i = componentBits.nextSetBit(i+1)) {
		fillBag.add(componentsByType.get(i).get(e.getId()));
	}
	
	return fillBag;
}
 
开发者ID:nhydock,项目名称:gdx-artemis,代码行数:10,代码来源:ComponentManager.java


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