IntBag.prototype.size=0; IntBag.prototype.clone = function() { var clone = new IntBag(); this.each(function(i, count) { clone.add(i, count);
/** 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; }
private void deletedAll(IntBag entities) { int[] ids = entities.getData(); for (int i = 0, s = entities.size(); s > i; i++) { int id = ids[i]; activeEntityIds.unsafeClear(id); removedIds.unsafeSet(id); } }
private int prepareBag(IntBag out, int elementsPerEntry) { int count = elementsPerEntry * cardinality(); out.ensureCapacity(count); out.setSize(count); return count; }
public void ensureCapacity(int newSize) { typeFactory.initialMapperCapacity = newSize; entityToIdentity.ensureCapacity(newSize); for (ComponentMapper mapper : mappers) { mapper.components.ensureCapacity(newSize); } }
private void purgeNoPool() { for (int id = idBits.nextSetBit(0); id >= 0; id = idBits.nextSetBit(id + 1)) { components.unsafeSet(id, null); } } }
/** Fetch unique identity for passed composition. */ int getIdentity(BitVector components) { BitVector[] 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; }
public void ensureCapacity(int newSize) { typeFactory.initialMapperCapacity = newSize; entityToIdentity.ensureCapacity(newSize); for (ComponentMapper mapper : mappers) { mapper.components.ensureCapacity(newSize); } }