本文整理了Java中com.artemis.utils.Bag.add()
方法的一些代码示例,展示了Bag.add()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bag.add()
方法的具体详情如下:
包路径:com.artemis.utils.Bag
类名称:Bag
方法名:add
[英]Adds the specified element to the end of this bag.
If required, it also increases the capacity of the bag.
[中]将指定的元素添加到此包的末尾。
如果需要,它还可以增加行李的容量。
代码示例来源:origin: stackoverflow.com
Bag myBag = new HashBag();
myBag.add("Orange");
myBag.add("Apple", 4);
myBag.add("Apple");
myBag.remove("Apple", 2);
int apples = myBag.getCount("Apple"); // Should be 3.
int kumquats = myBag.getCount("Kumquat"); // Should be 0.
代码示例来源:origin: junkdog/artemis-odb
/**
* Add listener interested in changes to the subscription.
*
* @param listener listener to add.
*/
public void addSubscriptionListener(SubscriptionListener listener) {
extra.listeners.add(listener);
}
代码示例来源:origin: junkdog/artemis-odb
/**
* Adds a {@link FieldResolver} to this handler. Resolvers added first, will be used first for resolving fields,
* so the order of add operations is significant.
*
* @param fieldResolver is added to this FieldHandler fieldresolver-list
*/
public final void addFieldResolver(FieldResolver fieldResolver) {
fieldResolvers.add(fieldResolver);
}
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb
/**
* Add listener interested in changes to the subscription.
*
* @param listener listener to add.
*/
public void addSubscriptionListener(SubscriptionListener listener) {
extra.listeners.add(listener);
}
代码示例来源:origin: net.mostlyoriginal.artemis-odb/contrib-eventbus
/** Subscribe listener to events. */
@Override
public void register( EventListener listener )
{
if ( !listeners.contains(listener) ) {
listeners.add(listener);
sortDirty =true;
}
}
代码示例来源:origin: junkdog/artemis-odb
public void setAll() {
array.add("array");
bag.add("bag");
hashSet.add("hashSet");
arrayList.add("arrayList");
list.add("list");
hashMap.put("key", "map");
intBag.add(1);
map.put("lock", "unlocked");
objectMap.put("obj", "map");
}
代码示例来源:origin: junkdog/artemis-odb
@Override
public Bag read(Json json, JsonValue jsonData, Class type) {
Bag<Entity> result = new Bag<Entity>();
for (JsonValue child = jsonData.child; child != null; child = child.next)
result.add(json.readValue(Entity.class, child));
return result;
}
}
代码示例来源:origin: junkdog/artemis-odb
/**
* Add all items into this bag.
*
* @param items
* bag with items to add
*/
public void addAll(ImmutableBag<E> items) {
for(int i = 0, s = items.size(); s > i; i++) {
add(items.get(i));
}
}
代码示例来源:origin: junkdog/artemis-odb
@Override
public Bag read(Json json, JsonValue jsonData, Class type) {
Bag<Entity> result = new Bag<Entity>();
for (JsonValue child = jsonData.child; child != null; child = child.next)
result.add(json.readValue(Entity.class, child));
return result;
}
}
代码示例来源:origin: junkdog/artemis-odb
/**
* Add new plugins.
*/
private void addPlugins(ArtemisPlugin[] plugins) {
for (ArtemisPlugin plugin : plugins) {
if (containsType(this.plugins, plugin.getClass())) {
throw new WorldConfigurationException("Plugin of type " + plugin.getClass() + " registered twice. Only once allowed.");
}
this.plugins.add(ConfigurationElement.of(plugin));
}
}
代码示例来源:origin: junkdog/artemis-odb
/**
* Add all items into this bag.
*
* @param items
* bag with items to add
*/
public void addAll(ImmutableBag<E> items) {
for(int i = 0, s = items.size(); s > i; i++) {
add(items.get(i));
}
}
代码示例来源:origin: junkdog/artemis-odb
Bag<Class<? extends Component>> getAdditions(Bag<Class<? extends Component>> out) {
for (int i = 0, s = additions.length; s > i; i++) {
out.add(additions[i].getType().getType());
}
return out;
}
代码示例来源:origin: junkdog/artemis-odb
private EntitySubscription createSubscription(Aspect.Builder builder) {
EntitySubscription entitySubscription = new EntitySubscription(world, builder);
subscriptionMap.put(builder, entitySubscription);
subscriptions.add(entitySubscription);
world.getComponentManager().synchronize(entitySubscription);
return entitySubscription;
}
代码示例来源:origin: net.onedaybeard.artemis/artemis-odb
protected void dependsOnSystem(int priority, Class<? extends BaseSystem> type) throws ReflectionException {
if (!containsType(systems, type)) {
this.systems.add(ConfigurationElement.of(ClassReflection.newInstance(type), priority));
}
}
代码示例来源:origin: junkdog/artemis-odb
int allocateIdentity(BitVector componentBits, ComponentManager cm) {
Bag<ComponentMapper> mappers =
new Bag<ComponentMapper>(ComponentMapper.class, componentBits.cardinality());
ComponentTypeFactory tf = cm.getTypeFactory();
for (int i = componentBits.nextSetBit(0); i >= 0; i = componentBits.nextSetBit(i + 1)) {
mappers.add(cm.getMapper(tf.getTypeFor(i).getType()));
}
compositionMappers.add(mappers);
compositionBits.add(new BitVector(componentBits));
return compositionBits.size() - 1;
}
}
代码示例来源:origin: junkdog/artemis-odb
@Override
public ArchetypeMapper.TransmuterEntry read(Json json, JsonValue jsonData, Class type) {
Bag components = new Bag();
for (JsonValue child = jsonData.child; child != null; child = child.next)
components.add(identifiers.getType(json.readValue(String.class, child)));
return new ArchetypeMapper.TransmuterEntry(components);
}
}
代码示例来源:origin: junkdog/artemis-odb
@Override
public void onCreated(ComponentType type) {
Bag<LinkSite> links = linkFactory.create(type);
if (links.isEmpty())
return;
for (int i = 0, s = links.size(); s > i; i++) {
elm.linkSites.add(links.get(i));
}
}
}
代码示例来源:origin: junkdog/artemis-odb
private void dependsOnPlugin(Class<? extends ArtemisPlugin> type) throws ReflectionException {
if (ClassReflection.isAbstractClass(type)) {
if (!anyAssignableTo(plugins, type)) {
throw new WorldConfigurationException("Implementation of " + type + " expected but not found. Did you forget to include a plugin? (for example: logging-libgdx for logging-api)");
}
} else {
if (!containsType(plugins, type)) {
this.plugins.add(ConfigurationElement.of(ClassReflection.newInstance(type)));
}
}
}
代码示例来源:origin: junkdog/artemis-odb
private Bag<ComponentMapper> getAdditions(BitVector origin) {
ComponentTypeFactory tf = cm.typeFactory;
Bag<ComponentMapper> types = new Bag(ComponentMapper.class);
for (int i = additions.nextSetBit(0); i >= 0; i = additions.nextSetBit(i + 1)) {
if (!origin.get(i))
types.add(cm.getMapper(tf.getTypeFor(i).getType()));
}
return types;
}
代码示例来源:origin: junkdog/artemis-odb
private Bag<ComponentMapper> getRemovals(BitVector origin) {
ComponentTypeFactory tf = cm.typeFactory;
Bag<ComponentMapper> types = new Bag(ComponentMapper.class);
for (int i = removals.nextSetBit(0); i >= 0; i = removals.nextSetBit(i + 1)) {
if (origin.get(i))
types.add(cm.getMapper(tf.getTypeFor(i).getType()));
}
return types;
}
}
内容来源于网络,如有侵权,请联系作者删除!