public static IntBag toIntBag(BitSet bs, IntBag out) { if (bs.isEmpty()) { out.setSize(0); return out; } int size = bs.cardinality(); out.setSize(size); out.ensureCapacity(size); int[] activesArray = out.getData(); for (int i = 0, id = -1, s = size; s > i; i++) { id = bs.nextSetBit(id + 1); activesArray[i] = id; } return out; }
public static IntBag toIntBag(BitSet bs, IntBag out) { if (bs.isEmpty()) { out.setSize(0); return out; } int size = bs.cardinality(); out.setSize(size); out.ensureCapacity(size); int[] activesArray = out.getData(); for (int i = 0, id = -1, s = size; s > i; i++) { id = bs.nextSetBit(id + 1); activesArray[i] = id; } return out; }
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; }
/** * Decodes the set bits as integers. The destination * {@link IntBag} is reset before the bits are transposed. * * @param out decoded ints end up here * @return Same as out */ public IntBag toIntBag(IntBag out) { if (isEmpty()) { out.setSize(0); return out; } int count = prepareBag(out, 1); int[] data = out.getData(); for (int i = 0, index = 0; count > index; i++) { long bitset = words[i]; int wordBits = i << 6; while (bitset != 0) { long t = bitset & -bitset; data[index] = wordBits + Long.bitCount(t - 1); bitset ^= t; index++; } } return out; }
void configureWith(int count) { poolIndex = 0; pool.setSize(0); pool.ensureCapacity(count); for (int i = 0; i < count; i++) { pool.add(world.create(archetype)); } Arrays.sort(pool.getData(), 0, pool.size()); }
/** * Decodes the set bits as integers. The destination * {@link IntBag} is reset before the bits are transposed. * * @param out decoded ints end up here * @return Same as out */ public IntBag toIntBag(IntBag out) { if (isEmpty()) { out.setSize(0); return out; } int count = prepareBag(out, 1); int[] data = out.getData(); for (int i = 0, index = 0; count > index; i++) { long bitset = words[i]; int wordBits = i << 6; while (bitset != 0) { long t = bitset & -bitset; data[index] = wordBits + Long.bitCount(t - 1); bitset ^= t; index++; } } return out; }
void configureWith(int count) { poolIndex = 0; pool.setSize(0); pool.ensureCapacity(count); for (int i = 0; i < count; i++) { pool.add(world.create(archetype)); } Arrays.sort(pool.getData(), 0, pool.size()); }
void informEntityChanges() { if (insertedIds.isEmpty() && removedIds.isEmpty()) return; transferBitsToInts(extra.inserted, extra.removed); extra.informEntityChanges(); entities.setSize(0); }
void informEntityChanges() { if (insertedIds.isEmpty() && removedIds.isEmpty()) return; transferBitsToInts(extra.inserted, extra.removed); extra.informEntityChanges(); entities.setSize(0); }
/** * Decodes the set bits as pairs of <code>entity id</code> and * {@link World#compositionId(int) compositionId}. The * destination{@link IntBag} is reset before the bits are * transposed. * * @param out decoded ints end up here * @return Same as out */ public IntBag toIntBagIdCid(ComponentManager cm, IntBag out) { if (isEmpty()) { out.setSize(0); return out; } int count = prepareBag(out, 2); int[] data = out.getData(); for (int i = 0, index = 0; count > index; i++) { long bitset = words[i]; int wordBits = i << 6; while (bitset != 0) { long t = bitset & -bitset; int id = wordBits + Long.bitCount(t - 1); data[index] = id; data[index + 1] = cm.getIdentity(id); index += 2; bitset ^= t; } } return out; }
/** * Decodes the set bits as integers. The destination * {@link IntBag} is reset before the bits are transposed. * * @param out decoded ints end up here * @return Same as out */ public IntBag toIntBag(IntBag out) { out.setSize(0); if (isEmpty()) return out; for (int id = nextSetBit(0); id >= 0; id = nextSetBit(id + 1)) { out.add(id); } return out; }
/** * Decodes the set bits as pairs of <code>entity id</code> and * {@link World#compositionId(int) compositionId}. The * destination{@link IntBag} is reset before the bits are * transposed. * * @param out decoded ints end up here * @return Same as out */ public IntBag toIntBagIdCid(ComponentManager cm, IntBag out) { if (isEmpty()) { out.setSize(0); return out; } int count = prepareBag(out, 2); int[] data = out.getData(); for (int i = 0, index = 0; count > index; i++) { long bitset = words[i]; int wordBits = i << 6; while (bitset != 0) { long t = bitset & -bitset; int id = wordBits + Long.bitCount(t - 1); data[index] = id; data[index + 1] = cm.getIdentity(id); index += 2; bitset ^= t; } } return out; }
/** * Decodes the set bits as pairs of <code>entity id</code> and * {@link World#compositionId(int) compositionId}. The * destination{@link IntBag} is reset before the bits are * transposed. * * @param out decoded ints end up here * @return Same as out */ public IntBag toIntBagIdCid(ComponentManager cm, IntBag out) { out.setSize(0); if (isEmpty()) return out; for (int id = nextSetBit(0); id >= 0; id = nextSetBit(id + 1)) { out.add(id); out.add(cm.getIdentity(id)); } return out; }