/** * Clear the info about which rows (in which original iterators and which row nums within them) were combined on * the previous step. */ private void clearCombinedRowsInfo() { for (int originalIteratorIndex = indexesOfCurrentlyCombinedOriginalIterators.nextSetBit(0); originalIteratorIndex >= 0; originalIteratorIndex = indexesOfCurrentlyCombinedOriginalIterators.nextSetBit(originalIteratorIndex + 1)) { minCurrentlyCombinedRowNumByOriginalIteratorIndex[originalIteratorIndex] = MIN_CURRENTLY_COMBINED_ROW_NUM_UNSET_VALUE; } indexesOfCurrentlyCombinedOriginalIterators.clear(); }
@Override protected void merge(ArrayState in1, ArrayState in2, ArrayState out) { out.active.clear(); out.active.or(in1.active); out.active.or(in2.active); BitSet in2_excl = (BitSet) in2.active.clone(); in2_excl.andNot(in1.active); for (int i = in1.active.nextSetBit(0); i >= 0; i = in1.active.nextSetBit(i + 1)) { if (in1.state[i] == null) { out.state[i] = null; } else if (in2.active.get(i)) { if (in2.state[i] == null) { out.state[i] = null; } else { out.state[i] = mergeTypeStates(in1.state[i], in2.state[i]); } } else { out.state[i] = in1.state[i]; } } for (int i = in2_excl.nextSetBit(0); i >= 0; i = in2_excl.nextSetBit(i + 1)) { out.state[i] = in2.state[i]; } }
/** * Performs a deep copy on <i>other</i>. */ public AccessControlEntry(AccessControlEntry other) { __isset_bit_vector.clear(); __isset_bit_vector.or(other.__isset_bit_vector); this.denyWrite = other.denyWrite; this.denyTruncate = other.denyTruncate; this.denyDelete = other.denyDelete; this.denyAcquire = other.denyAcquire; this.denyRelease = other.denyRelease; }
final BitSet parent2Key = second.getRepresentation(); final BitSet child1Key = new BitSet(length); final BitSet child2Key = new BitSet(length); a.clear(crossoverIndex, length); BitSet b = (BitSet) parent2Key.clone(); b.clear(0, crossoverIndex); c.clear(crossoverIndex, length); BitSet d = (BitSet) parent2Key.clone(); d.clear(0, crossoverIndex); child1Key.or(a); child1Key.or(d); child2Key.or(c); child2Key.or(b); return new ChromosomePair(first.newBitsChromosome(child1Key), second.newBitsChromosome(child2Key));
private void setPostRegisterTypeAndPropagateChanges(AnalyzedInstruction analyzedInstruction, int registerNumber, RegisterType registerType) { BitSet changedInstructions = new BitSet(instructions.size()); for (int instructionIndex=changedInstructions.nextSetBit(0); instructionIndex>=0; instructionIndex=changedInstructions.nextSetBit(instructionIndex+1)) { changedInstructions.clear(instructionIndex);
/** * Reservoir sampling algorithm borrowed from Stack Overflow. * https://stackoverflow.com/questions/12817946/generate-a-random-bitset-with-n-1s */ private static BitSet randomBitSet(int size, int cardinality, Random rnd) { final BitSet result = new BitSet(size); final int[] chosen = new int[cardinality]; int i; for (i = 0; i < cardinality; ++i) { chosen[i] = i; result.set(i); } for (; i < size; ++i) { final int j = rnd.nextInt(i + 1); if (j < cardinality) { result.clear(chosen[j]); result.set(i); chosen[j] = i; } } return result; }
/** Unsupported operation. */ @Override public boolean remove(Object o) { if (o == null) throw new UnsupportedOperationException("Null values are not supported!"); int val = (int)o; if (val < 0) throw new UnsupportedOperationException("Negative values are not supported!"); boolean alreadySet = bitSet.get(val); if (alreadySet) { bitSet.clear(val); size--; } return alreadySet; }
/** * Remove exception handlers from block nodes bitset */ public static void cleanBitSet(MethodNode mth, BitSet bs) { for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { BlockNode block = mth.getBasicBlocks().get(i); if (isBlockMustBeCleared(block)) { bs.clear(i); } } }
private void makeSureAllElementAreAssigned(Map<Local, ArrayObject> arraySizes) { BitSet pos = new BitSet(); for (Iterator<Map.Entry<Local, ArrayObject>> it = arraySizes.entrySet().iterator(); it.hasNext();) { Map.Entry<Local, ArrayObject> e = it.next(); if (p.st == Stmt.ST.FILL_ARRAY_DATA) { int endPos = Array.getLength(((Constant) p.getOp2()).value); int next = pos.nextSetBit(0); if (next < 0 || next >= endPos) {// not set in range pos.set(0, endPos); } else {// setted in range needRemove = true; ArrayExpr ae = (ArrayExpr) p.getOp1(); int idx = ((Number) ((Constant) ae.getOp2()).value).intValue(); if (!pos.get(idx)) { pos.set(idx); } else { needRemove = true; if (needRemove || pos.nextClearBit(0) < arrayObject.size || pos.nextSetBit(arrayObject.size) >= 0) { it.remove(); pos.clear();