本文整理了Java中java.util.BitSet.previousClearBit()
方法的一些代码示例,展示了BitSet.previousClearBit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BitSet.previousClearBit()
方法的具体详情如下:
包路径:java.util.BitSet
类名称:BitSet
方法名:previousClearBit
[英]Returns the index of the first bit that is clear on or before index, or -1 if no lower bits are clear or index == -1.
[中]返回在索引上或之前清除的第一位的索引,如果没有较低的位清除,则返回-1,或者返回索引==-1。
代码示例来源:origin: pmd/pmd
@Override
public List<Variable> next() {
BitSet resultBitSet = (BitSet) nextBitSet.clone();
int b = nextBitSet.previousClearBit(n - 1);
int b1 = nextBitSet.previousSetBit(b);
if (b1 == -1) {
advanceToNextK();
} else {
nextBitSet.clear(b1);
nextBitSet.set(b1 + 1, b1 + (n - b) + 1);
nextBitSet.clear(b1 + (n - b) + 1, n);
}
resultList.clear();
for (int i = 0; i < n; ++i) {
if (resultBitSet.get(i)) {
resultList.add(permuteThis.get(i));
}
}
return unmodifyableViewOfResult;
}
}
代码示例来源:origin: vsch/flexmark-java
public int previousClearBit(int i) {return myBits.previousClearBit(i);}
public boolean intersects(BitSet set) {return myBits.intersects(set);}
代码示例来源:origin: apache/asterixdb
private static int getLastUnusedPos(BitSet used, int lastPos) {
return used.previousClearBit(lastPos);
}
代码示例来源:origin: com.vladsch.flexmark/flexmark-util
public int previousClearBit(int i) {return myBits.previousClearBit(i);}
public boolean intersects(BitSet set) {return myBits.intersects(set);}
代码示例来源:origin: chocoteam/choco-solver
@Override
public int previousValueOut(int aValue) {
int val = aValue - offset;
if(val <= -1 || val > values.length()){
return aValue - 1;
}else{
val = values.previousClearBit(val - 1);
return val + offset;
}
}
代码示例来源:origin: stackoverflow.com
int maxNumberOfConsecutiveBits(BitSet bs) {
int maxLength = 0;
int onesI = bs.length(); // Points to the prior 0.
for (int i = onesI; (i = bs.previousClearBit(i - 1)) >= 0; ) {
int length = onesI - 1 - i;
maxLength = Math.max(maxLength, length);
i = bs.previousSetBit(i - 1) + 1; // Heuristic, optional.
onesI = i;
}
return maxLength;
}
代码示例来源:origin: stackoverflow.com
static void genCombinations(int n, int k) {
BitSet bs = new BitSet(n);
bs.set(0, k);
while(true) {
// output
for(int i=0; i<n; i++)
System.out.print(bs.get(i) ? "1" : "0");
System.out.println();
int b = bs.previousClearBit(n-1); // the last zero
int b1 = bs.previousSetBit(b); // the last one before that zero
if(b1 == -1)
return;
bs.clear(b1);
bs.set(b1+1, b1+(n-b)+1);
bs.clear(b1+(n-b)+1, n);
}
}
public static void main(String[] args) {
genCombinations(5, 3);
}
代码示例来源:origin: net.sourceforge.pmd/pmd-java
@Override
public List<Variable> next() {
BitSet resultBitSet = (BitSet) nextBitSet.clone();
int b = nextBitSet.previousClearBit(n - 1);
int b1 = nextBitSet.previousSetBit(b);
if (b1 == -1) {
advanceToNextK();
} else {
nextBitSet.clear(b1);
nextBitSet.set(b1 + 1, b1 + (n - b) + 1);
nextBitSet.clear(b1 + (n - b) + 1, n);
}
resultList.clear();
for (int i = 0; i < n; ++i) {
if (resultBitSet.get(i)) {
resultList.add(permuteThis.get(i));
}
}
return unmodifyableViewOfResult;
}
}
代码示例来源:origin: com.github.bingoohuang/idworker-client
private int tryFindAvailableCode(int code) {
int next = codesFilter.nextClearBit(code);
if (next != -1 && next < max(maxRandomSize)) return add(next);
next = codesFilter.previousClearBit(code);
if (next != -1) return add(next);
return -1;
}
代码示例来源:origin: leechenxiang/imooc-springboot-starter
private int tryFindAvailableCode(int code) {
int next = codesFilter.nextClearBit(code);
if (next != -1 && next < max(maxRandomSize)) return add(next);
next = codesFilter.previousClearBit(code);
if (next != -1) return add(next);
return -1;
}
代码示例来源:origin: RAOE/show-videos
private int tryFindAvailableCode(int code) {
int next = codesFilter.nextClearBit(code);
if (next != -1 && next < max(maxRandomSize))
return add(next);
next = codesFilter.previousClearBit(code);
if (next != -1)
return add(next);
return -1;
}
代码示例来源:origin: stackoverflow.com
for (int i = 0; i < n; i++)
res[i] = bs.get(i) ? '1' : '0';
int b = bs.previousClearBit(n - 1);
int b1 = bs.previousSetBit(b);
if (b1 == -1)
代码示例来源:origin: schierlm/BibleMultiConverter
if (!bits.isEmpty()) {
to = bits.previousSetBit(bits.length());
from = bits.previousClearBit(to) + 1;
bits.clear(from, to + 1);
BitSet old = bits;
代码示例来源:origin: Camelcade/Perl5-IDEA
int commentLine = getNodeLine(childNode);
if (myCommentsLines.get(commentLine)) {
return myCommentsAlignmentMap.get(myCommentsLines.previousClearBit(commentLine));
内容来源于网络,如有侵权,请联系作者删除!