@Override public String toString() { int cardinality = cardinality(); int end = Math.min(128, cardinality); int count = 0; StringBuilder sb = new StringBuilder(); sb.append("BitVector[").append(cardinality); if (cardinality > 0) { sb.append(": {"); for (int i = nextSetBit(0); end > count && i != -1; i = nextSetBit(i + 1)) { if (count != 0) sb.append(", "); sb.append(i); count++; } if (cardinality > end) sb.append(" ..."); sb.append("}"); } sb.append("]"); return sb.toString(); } }
@Override public String toString() { int cardinality = cardinality(); int end = Math.min(128, cardinality); int count = 0; StringBuilder sb = new StringBuilder(); sb.append("BitVector[").append(cardinality); if (cardinality > 0) { sb.append(": {"); for (int i = nextSetBit(0); end > count && i != -1; i = nextSetBit(i + 1)) { if (count != 0) sb.append(", "); sb.append(i); count++; } if (cardinality > end) sb.append(" ..."); sb.append("}"); } sb.append("]"); return sb.toString(); } }
private int prepareBag(IntBag out, int elementsPerEntry) { int count = elementsPerEntry * cardinality(); out.ensureCapacity(count); out.setSize(count); return count; }
private int prepareBag(IntBag out, int elementsPerEntry) { int count = elementsPerEntry * cardinality(); out.ensureCapacity(count); out.setSize(count); return count; }
/** * <p>If all entties have been deleted, resets the entity cache - with next entity * entity receiving id <code>0</code>. There mustn't be any active entities in * the world for this method to work. This method does nothing if it fails.</p> * * <p>For the reset to take effect, a new {@link World#process()} must initiate.</p> * * @return true if entity id was successfully reset. * */ public boolean reset() { int count = world.getAspectSubscriptionManager() .get(all()) .getActiveEntityIds() .cardinality(); if (count > 0) return false; limbo.clear(); recycled.clear(); entities.clear(); nextId = 0; return true; }
/** * <p>If all entties have been deleted, resets the entity cache - with next entity * entity receiving id <code>0</code>. There mustn't be any active entities in * the world for this method to work. This method does nothing if it fails.</p> * * <p>For the reset to take effect, a new {@link World#process()} must initiate.</p> * * @return true if entity id was successfully reset. * */ public boolean reset() { int count = world.getAspectSubscriptionManager() .get(all()) .getActiveEntityIds() .cardinality(); if (count > 0) return false; limbo.clear(); recycled.clear(); entities.clear(); nextId = 0; return true; }
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; } }
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; } }
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; } }