本文整理了Java中java.util.BitSet.nextSetBit()
方法的一些代码示例,展示了BitSet.nextSetBit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BitSet.nextSetBit()
方法的具体详情如下:
包路径:java.util.BitSet
类名称:BitSet
方法名:nextSetBit
[英]Returns the index of the first bit that is set on or after index, or -1 if no higher bits are set.
[中]返回在索引上或之后设置的第一位的索引,如果未设置更高的位,则返回-1。
代码示例来源:origin: apache/incubator-druid
/**
* 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();
}
代码示例来源:origin: checkstyle/checkstyle
/**
* Creates new instance for nested structure.
* @param base parent's level
* @param offsets offsets from parent's level.
*/
public IndentLevel(IndentLevel base, int... offsets) {
final BitSet src = base.levels;
for (int i = src.nextSetBit(0); i >= 0; i = src.nextSetBit(i + 1)) {
for (int offset : offsets) {
levels.set(i + offset);
}
}
}
代码示例来源:origin: skylot/jadx
public static List<BlockNode> bitSetToBlocks(MethodNode mth, BitSet bs) {
int size = bs.cardinality();
if (size == 0) {
return Collections.emptyList();
}
List<BlockNode> blocks = new ArrayList<>(size);
for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
BlockNode block = mth.getBasicBlocks().get(i);
blocks.add(block);
}
return blocks;
}
代码示例来源:origin: skylot/jadx
private static void placePhi(MethodNode mth, int regNum, LiveVarAnalysis la) {
List<BlockNode> blocks = mth.getBasicBlocks();
int blocksCount = blocks.size();
BitSet hasPhi = new BitSet(blocksCount);
BitSet processed = new BitSet(blocksCount);
Deque<BlockNode> workList = new LinkedList<>();
BitSet assignBlocks = la.getAssignBlocks(regNum);
for (int id = assignBlocks.nextSetBit(0); id >= 0; id = assignBlocks.nextSetBit(id + 1)) {
processed.set(id);
workList.add(blocks.get(id));
}
while (!workList.isEmpty()) {
BlockNode block = workList.pop();
BitSet domFrontier = block.getDomFrontier();
for (int id = domFrontier.nextSetBit(0); id >= 0; id = domFrontier.nextSetBit(id + 1)) {
if (!hasPhi.get(id) && la.isLive(id, regNum)) {
BlockNode df = blocks.get(id);
addPhi(mth, df, regNum);
hasPhi.set(id);
if (!processed.get(id)) {
processed.set(id);
workList.add(df);
}
}
}
}
}
代码示例来源:origin: RoaringBitmap/RoaringBitmap
@Benchmark
public BitSet bitset() {
BitSet result = new BitSet();
for(int i = 0; i < bitSets.length; ++i) {
BitSetWithOffset bit = bitSets[i];
int currentBit = bit.bitset.nextSetBit(0);
while(currentBit != -1) {
result.set(currentBit + bit.offset);
currentBit = bit.bitset.nextSetBit(currentBit + 1);
}
}
return result;
}
代码示例来源:origin: spotbugs/spotbugs
if(origNumber != null) {
for(ValueInfo vi : vals) {
if(vi.origValues.get(origNumber.getNumber()) && !vi.derivedValues.get(number)) {
vi.derivedValues.set(number);
result = true;
for (int i = outputSet.nextSetBit(0); i >= 0; i = outputSet.nextSetBit(i+1)) {
list = values.get(i);
if(list == null) {
代码示例来源:origin: Sable/soot
@SuppressWarnings("unchecked")
public ArrayTypes getArrayTypesBefore(Stmt s, Local arrayLocal) {
if (!isConstantBefore(s, arrayLocal)) {
return null;
}
ArrayTypes toRet = new ArrayTypes();
int varRef = localToInt.get(arrayLocal);
ArrayTypesInternal ati = getFlowBefore(s).state[varRef];
toRet.possibleSizes = new HashSet<Integer>();
toRet.possibleTypes = new Set[ati.typeState.length];
for (int i = ati.sizeState.nextSetBit(0); i >= 0; i = ati.sizeState.nextSetBit(i + 1)) {
toRet.possibleSizes.add(rvSizeToInt.get(i));
}
for (int i = 0; i < toRet.possibleTypes.length; i++) {
toRet.possibleTypes[i] = new HashSet<Type>();
for (int j = ati.typeState[i].nextSetBit(0); j >= 0; j = ati.typeState[i].nextSetBit(j + 1)) {
toRet.possibleTypes[i].add(rvTypeToInt.get(j));
}
if (!ati.mustAssign.get(i)) {
toRet.possibleTypes[i].add(NullType.v());
}
}
return toRet;
}
代码示例来源:origin: google/guava
static CharMatcher from(BitSet chars, String description) {
// Compute the filter.
long filter = 0;
int size = chars.cardinality();
boolean containsZero = chars.get(0);
// Compute the hash table.
char[] table = new char[chooseTableSize(size)];
int mask = table.length - 1;
for (int c = chars.nextSetBit(0); c != -1; c = chars.nextSetBit(c + 1)) {
// Compute the filter at the same time.
filter |= 1L << c;
int index = smear(c) & mask;
while (true) {
// Check for empty.
if (table[index] == 0) {
table[index] = (char) c;
break;
}
// Linear probing.
index = (index + 1) & mask;
}
}
return new SmallCharMatcher(table, filter, containsZero, description);
}
代码示例来源:origin: Sable/soot
@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];
}
}
代码示例来源:origin: sonyxperiadev/ApkAnalyser
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);
代码示例来源:origin: osmandapp/Osmand
protected Object calcSelectValue(BitSet types, ParameterContext paramContext) {
if (selectValue instanceof String && selectValue.toString().startsWith("$")) {
BitSet mask = tagRuleMask.get(selectValue.toString().substring(1));
if (mask != null && mask.intersects(types)) {
BitSet findBit = new BitSet(mask.length());
findBit.or(mask);
findBit.and(types);
int value = findBit.nextSetBit(0);
return parseValueFromTag(value, selectType);
}
} else if (selectValue instanceof String && selectValue.toString().startsWith(":")) {
String p = ((String) selectValue).substring(1);
if (paramContext != null && paramContext.vars.containsKey(p)) {
selectValue = parseValue(paramContext.vars.get(p), selectType);
} else {
return null;
}
}
return selectValue;
}
代码示例来源:origin: opentripplanner/OpenTripPlanner
public boolean doOneRound (int[] bestTimes, int[] bestNonTransferTimes, int[] previousPatterns, boolean useFrequencies) {
stopsTouched.clear(); // clear any stops left over from previous round.
PATTERNS: for (int p = patternsTouched.nextSetBit(0); p >= 0; p = patternsTouched.nextSetBit(p+1)) {
bestNonTransferTimes[stopIndex] = remainOnBoardTime;
stopsTouched.set(stopIndex);
allStopsTouched.set(stopIndex);
bestNonTransferTimes[stopIndex] = arrivalTime;
stopsTouched.set(stopIndex);
allStopsTouched.set(stopIndex);
代码示例来源:origin: mpetazzoni/ttorrent
BitSet availablePieces = peer.getAvailablePieces();
for (int i = availablePieces.nextSetBit(0); i >= 0;
i = availablePieces.nextSetBit(i + 1)) {
this.pieces[i].noLongerAt(peer);
if (requested != null) {
for (Piece piece : requested) {
this.requestedPieces.set(piece.getIndex(), false);
new Object[]{
peer,
availablePieces.cardinality(),
this.completedPieces.cardinality(),
this.pieces.length
});
logger.trace("We now have {} piece(s) and {} outstanding request(s): {}",
new Object[]{
this.completedPieces.cardinality(),
this.requestedPieces.cardinality(),
this.requestedPieces
代码示例来源:origin: spotbugs/spotbugs
public BitSet getTransitiveOutputSet(int input) {
BitSet visited = new BitSet();
BitSet result = new BitSet();
LinkedList<Integer> workList = new LinkedList<>();
workList.addLast(input);
while (!workList.isEmpty()) {
Integer valueNumber = workList.removeFirst();
visited.set(valueNumber);
BitSet outputSet = getOutputSet(valueNumber);
result.or(outputSet);
for (int i = outputSet.nextSetBit(0); i >= 0; i = outputSet.nextSetBit(i+1)) {
if (!visited.get(i)) {
workList.addLast(i);
}
}
}
return result;
}
代码示例来源:origin: fesh0r/fernflower
public ConstantPool(DataInputStream in) throws IOException {
int size = in.readUnsignedShort();
pool = new ArrayList<>(size);
BitSet[] nextPass = {new BitSet(size), new BitSet(size), new BitSet(size)};
case CodeConstants.CONSTANT_MethodType:
pool.add(new PrimitiveConstant(tag, in.readUnsignedShort()));
nextPass[0].set(i);
break;
nextPass[0].set(i);
break;
case CodeConstants.CONSTANT_InvokeDynamic:
pool.add(new LinkConstant(tag, in.readUnsignedShort(), in.readUnsignedShort()));
nextPass[1].set(i);
break;
while ((idx = pass.nextSetBit(idx + 1)) > 0) {
pool.get(idx).resolveConstant(this);
代码示例来源:origin: pxb1988/dex2jar
DexStmtNode p = stack.pop();
int index = p.__index;
if (!access.get(index)) {
access.set(index);
} else {
continue;
if (handlers.get(index)) {
Local ex = newLocal();
emit(Stmts.nIdentity(ex, Exprs.nExceptionRef("Ljava/lang/Throwable;")));
for (int i = ex.nextSetBit(0); i >= 0; i = ex.nextSetBit(i + 1)) {
merge(frame, i);
stack.push(insnList.get(i));
代码示例来源:origin: Sable/soot
if (bits.get(fromIndex)) {
return singletonList(universe[fromIndex]);
int i = bits.nextSetBit(fromIndex);
if (i < 0 || i >= toIndex) {
return emptyList();
break;
i = bits.nextSetBit(i + 1);
if (i < 0 || i >= toIndex) {
break;
代码示例来源:origin: prestodb/presto
static CharMatcher from(BitSet chars, String description) {
// Compute the filter.
long filter = 0;
int size = chars.cardinality();
boolean containsZero = chars.get(0);
// Compute the hash table.
char[] table = new char[chooseTableSize(size)];
int mask = table.length - 1;
for (int c = chars.nextSetBit(0); c != -1; c = chars.nextSetBit(c + 1)) {
// Compute the filter at the same time.
filter |= 1L << c;
int index = smear(c) & mask;
while (true) {
// Check for empty.
if (table[index] == 0) {
table[index] = (char) c;
break;
}
// Linear probing.
index = (index + 1) & mask;
}
}
return new SmallCharMatcher(table, filter, containsZero, description);
}
代码示例来源:origin: spotbugs/spotbugs
void enhanceViaMergeTree() {
values = new HashMap<>();
for (Entry<Integer, ValueInfo> entry : observedValues.entrySet()) {
BitSet outputSet = vna.getMergeTree().getTransitiveOutputSet(entry.getKey());
outputSet.set(entry.getKey());
entry.getValue().origValues = outputSet;
for (int i = outputSet.nextSetBit(0); i >= 0; i = outputSet.nextSetBit(i+1)) {
Set<ValueInfo> list = values.get(i);
if(list == null) {
list = new HashSet<>();
values.put(i, list);
}
list.add(entry.getValue());
}
}
}
代码示例来源:origin: skylot/jadx
/**
* 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);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!