com.artemis.utils.Bag.size()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中com.artemis.utils.Bag.size()方法的一些代码示例,展示了Bag.size()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bag.size()方法的具体详情如下:
包路径:com.artemis.utils.Bag
类名称:Bag
方法名:size

Bag.size介绍

[英]The amount of elements contained in bag.
[中]袋中所含元素的数量。

代码示例

代码示例来源:origin: junkdog/artemis-odb

@Override
public String toString() {
  return "EntityReference{" +
      componentType.getSimpleName() +
      "." + field.getName() +
      " (" + fieldType +
      "), operations=" + operations.size() +
      '}';
}

代码示例来源:origin: junkdog/artemis-odb

EntityReference find(Class<?> componentType, String fieldName) {
  for (int i = 0, s = referenced.size(); s > i; i++) {
    EntityReference ref = referenced.get(i);
    if (ref.componentType.equals(componentType) && ref.field.getName().equals(fieldName))
      return ref;
  }
  throw new RuntimeException(
      componentType.getSimpleName() + "." + fieldName);
}

代码示例来源:origin: net.onedaybeard.artemis/artemis-odb-serializer

EntityReference find(Class<?> componentType, String fieldName) {
  for (int i = 0, s = referenced.size(); s > i; i++) {
    EntityReference ref = referenced.get(i);
    if (ref.componentType.equals(componentType) && ref.field.getName().equals(fieldName))
      return ref;
  }
  throw new RuntimeException(
      componentType.getSimpleName() + "." + fieldName);
}

代码示例来源:origin: junkdog/artemis-odb

/** Converts java classes to component types. */
  private ComponentType[] resolveTypes(World world) {
    ComponentTypeFactory tf = world.getComponentManager().typeFactory;
    ComponentType[] types = new ComponentType[classes.size()];
    for (int i = 0, s = classes.size(); s > i; i++)
      types[i] = tf.getTypeFor(classes.get(i));
    
    return types;
  }
}

代码示例来源:origin: net.onedaybeard.artemis/artemis-odb

/** Converts java classes to component types. */
  private ComponentType[] resolveTypes(World world) {
    ComponentTypeFactory tf = world.getComponentManager().typeFactory;
    ComponentType[] types = new ComponentType[classes.size()];
    for (int i = 0, s = classes.size(); s > i; i++)
      types[i] = tf.getTypeFor(classes.get(i));
    
    return types;
  }
}

代码示例来源:origin: junkdog/artemis-odb

void processComponentIdentity(int id, BitVector componentBits) {
  for (int i = 0, s = subscriptions.size(); s > i; i++) {
    subscriptions.get(i).processComponentIdentity(id, componentBits);
  }
}

代码示例来源:origin: junkdog/artemis-odb

@Override
public void initialize(Bag<ComponentType> types) {
  for (int i = 0, s = types.size(); s > i; i++) {
    onCreated(types.get(i));
  }
}

代码示例来源:origin: junkdog/artemis-odb

private void initializeSystems(Injector injector) {
  for (int i = 0, s = systems.size(); i < s; i++) {
    BaseSystem system = systems.get(i);
    injector.inject(system);
  }
  for (int i = 0, s = systems.size(); i < s; i++) {
    BaseSystem system = systems.get(i);
    system.initialize();
  }
}

代码示例来源:origin: junkdog/artemis-odb

/** Fetch unique identity for passed composition. */
int getIdentity(BitVector components) {
  Object[] bitsets = compositionBits.getData();
  int size = compositionBits.size();
  for (int i = NO_COMPONENTS; size > i; i++) { // want to start from 1 so that 0 can mean null
    if (components.equals(bitsets[i]))
      return i;
  }
  return -1;
}

代码示例来源:origin: net.onedaybeard.artemis/artemis-odb

private void initializeSystems(Injector injector) {
  for (int i = 0, s = systems.size(); i < s; i++) {
    BaseSystem system = systems.get(i);
    injector.inject(system);
  }
  for (int i = 0, s = systems.size(); i < s; i++) {
    BaseSystem system = systems.get(i);
    system.initialize();
  }
}

代码示例来源:origin: net.onedaybeard.artemis/artemis-odb

void processComponentIdentity(int id, BitVector componentBits) {
  for (int i = 0, s = subscriptions.size(); s > i; i++) {
    subscriptions.get(i).processComponentIdentity(id, componentBits);
  }
}

代码示例来源:origin: junkdog/artemis-odb

private int getComponentCount(SaveFileFormat.ComponentIdentifiers identifiers) {
  int count = 0;
  for (int i = 0, s = components.size(); s > i; i++) {
    Component c = components.get(i);
    if (identifiers.isTransient(c.getClass()))
      continue;
    if (defaultValues.hasDefaultValues(c))
      continue;
    count++;
  }
  return count;
}

代码示例来源:origin: junkdog/artemis-odb

/** @inheritDoc */
  @Override
  protected final void processSystem() {
    Bag<Entity> entities = getEntities();
    Object[] array = entities.getData();
    for (int i = 0, s = entities.size(); s > i; i++) {
      process((Entity) array[i]);
    }
  }
}

代码示例来源:origin: junkdog/artemis-odb

@SuppressWarnings("unchecked")
<T extends PooledComponent> T obtain() {
  try {
    return (T) ((cache.size() > 0)
      ? cache.removeLast()
      : ClassReflection.newInstance(type));
  } catch (ReflectionException e) {
    throw new InvalidComponentException(type, e.getMessage(), e);
  }
}

代码示例来源:origin: junkdog/artemis-odb

private void removeComponents(int entityId) {
  Bag<ComponentMapper> mappers = componentMappers(entityId);
  for (int i = 0, s = mappers.size(); s > i; i++) {
    mappers.get(i).internalRemove(entityId);
  }
  setIdentity(entityId, 0);
}

代码示例来源: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 informListeners() {
    for (int i = 0, s = listeners.size(); s > i; i++) {
      SubscriptionListener listener = listeners.get(i);
      if (removed.size() > 0)
        listener.removed(removed);
      if (inserted.size() > 0)
        listener.inserted(inserted);
    }
  }
}

代码示例来源:origin: junkdog/artemis-odb

private void growEntityStores() {
  int newSize = 2 * entities.getCapacity();
  entities.ensureCapacity(newSize);
  ComponentManager cm = world.getComponentManager();
  cm.ensureCapacity(newSize);
  for (int i = 0, s = entityBitVectors.size(); s > i; i++) {
    entityBitVectors.get(i).ensureCapacity(newSize);
  }
}

代码示例来源:origin: junkdog/artemis-odb

@Override
public void validate(int sourceId, Bag<Entity> entities, LinkListener listener) {
  for (int i = 0; entities.size() > i; i++) {
    Entity e = entities.get(i);
    if (!all.getActiveEntityIds().unsafeGet(e.getId())) {
      entities.remove(i--);
      if (listener != null)
        listener.onTargetDead(sourceId, e.getId());
    }
  }
}

代码示例来源: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;
  }
}

相关文章