本文整理了Java中java.util.BitSet.nextClearBit()
方法的一些代码示例,展示了BitSet.nextClearBit()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BitSet.nextClearBit()
方法的具体详情如下:
包路径:java.util.BitSet
类名称:BitSet
方法名:nextClearBit
[英]Returns the index of the first bit that is clear on or after index. Since all bits past the end are implicitly clear, this never returns -1.
[中]返回在索引上或之后清除的第一位的索引。由于结束后的所有位都是隐式清除的,因此它永远不会返回-1。
代码示例来源:origin: graphhopper/graphhopper
public final int nextClear(int index) {
return super.nextClearBit(index);
}
代码示例来源:origin: org.apache.poi/poi-ooxml
@SuppressWarnings("WeakerAccess")
protected int allocateShapeId() {
final int nextId = shapeIds.nextClearBit(1);
shapeIds.set(nextId);
return nextId;
}
代码示例来源:origin: konsoletyper/teavm
public boolean hasLowHighSurrogates() {
return altSurrogates ? lowHighSurrogates.nextClearBit(0) < SURROGATE_CARDINALITY : lowHighSurrogates
.nextSetBit(0) < SURROGATE_CARDINALITY;
}
代码示例来源:origin: com.h2database/h2
/**
* Get the position of the first free space.
*
* @return the position.
*/
public long getFirstFree() {
return getPos(set.nextClearBit(0));
}
代码示例来源:origin: neo4j/neo4j
private static void assertAllIdsOccupied( long highId, BitSet seenIds )
{
long expectedNumberOfPages = highId - IdSpace.MIN_TREE_NODE_ID;
if ( seenIds.cardinality() != expectedNumberOfPages )
{
StringBuilder builder = new StringBuilder( "[" );
int index = (int) IdSpace.MIN_TREE_NODE_ID;
int count = 0;
while ( index >= 0 && index < highId )
{
index = seenIds.nextClearBit( index );
if ( index != -1 )
{
if ( count++ > 0 )
{
builder.append( "," );
}
builder.append( index );
index++;
}
}
builder.append( "]" );
throw new RuntimeException( "There are " + count + " unused pages in the store:" + builder );
}
}
代码示例来源:origin: facebook/litho
/**
* Checks that all the required props are supplied, and if not throws a useful exception
*
* @param requiredPropsCount expected number of props
* @param required the bit set that identifies which props have been supplied
* @param requiredPropsNames the names of all props used for a useful error message
*/
protected static void checkArgs(
int requiredPropsCount, BitSet required, String[] requiredPropsNames) {
if (required != null && required.nextClearBit(0) < requiredPropsCount) {
List<String> missingProps = new ArrayList<>();
for (int i = 0; i < requiredPropsCount; i++) {
if (!required.get(i)) {
missingProps.add(requiredPropsNames[i]);
}
}
throw new IllegalStateException(
"The following props are not marked as optional and were not supplied: "
+ Arrays.toString(missingProps.toArray()));
}
}
代码示例来源:origin: facebook/litho
/**
* Checks that all the required props are supplied, and if not throws a useful exception
*
* @param requiredPropsCount expected number of props
* @param required the bit set that identifies which props have been supplied
* @param requiredPropsNames the names of all props used for a useful error message
*/
protected static void checkArgs(
int requiredPropsCount, BitSet required, String[] requiredPropsNames) {
if (required != null && required.nextClearBit(0) < requiredPropsCount) {
List<String> missingProps = new ArrayList<>();
for (int i = 0; i < requiredPropsCount; i++) {
if (!required.get(i)) {
missingProps.add(requiredPropsNames[i]);
}
}
throw new IllegalStateException(
"The following props are not marked as optional and were not supplied: "
+ Arrays.toString(missingProps.toArray()));
}
}
}
代码示例来源:origin: org.apache.poi/poi
/**
* Finds the next available (1 based) drawing group id
*
* @return the next available drawing group id
*/
public short findNewDrawingGroupId() {
BitSet bs = new BitSet();
bs.set(0);
for (FileIdCluster fic : field_5_fileIdClusters) {
bs.set(fic.getDrawingGroupId());
}
return (short)bs.nextClearBit(0);
}
代码示例来源:origin: org.apache.commons/commons-lang3
destIndex += count;
srcIndex = indices.nextClearBit(set);
代码示例来源:origin: apache/ignite
/**
* @param commState Node communication state.
* @param initialNodes Topology snapshot when communication error resolve started.
* @param top Current topology.
* @return {@code True} if node has connection to all alive nodes.
*/
private boolean checkFullyConnected(BitSet commState, List<ClusterNode> initialNodes, ZkClusterNodes top) {
int startIdx = 0;
for (;;) {
int idx = commState.nextClearBit(startIdx);
if (idx >= initialNodes.size())
return true;
ClusterNode node = initialNodes.get(idx);
if (top.nodesById.containsKey(node.id()))
return false;
startIdx = idx + 1;
}
}
代码示例来源:origin: com.h2database/h2
/**
* Allocate a number of blocks and mark them as used.
*
* @param length the number of bytes to allocate
* @return the start position in bytes
*/
public long allocate(int length) {
int blocks = getBlockCount(length);
for (int i = 0;;) {
int start = set.nextClearBit(i);
int end = set.nextSetBit(start + 1);
if (end < 0 || end - start >= blocks) {
set.set(start, start + blocks);
return getPos(start);
}
i = end;
}
}
代码示例来源:origin: pxb1988/dex2jar
if (needRemove || pos.nextClearBit(0) < arrayObject.size || pos.nextSetBit(arrayObject.size) >= 0) {
it.remove();
代码示例来源:origin: Sable/soot
private List<T> toList(BitSet bits, int base) {
final int len = bits.cardinality();
switch (len) {
case 0:
return emptyList();
case 1:
return singletonList(map.getObject((base - 1) + bits.length()));
default:
List<T> elements = new ArrayList<T>(len);
int i = bits.nextSetBit(0);
do {
int endOfRun = bits.nextClearBit(i + 1);
do {
elements.add(map.getObject(base + i++));
} while (i < endOfRun);
i = bits.nextSetBit(i + 1);
} while (i >= 0);
return elements;
}
}
代码示例来源:origin: apache/flink
@Override
public void invoke(Integer value) throws Exception {
numElements++;
if (duplicateChecker.get(value)) {
throw new Exception("Received a duplicate: " + value);
}
duplicateChecker.set(value);
if (numElements == numElementsTotal) {
// validate
if (duplicateChecker.cardinality() != numElementsTotal) {
throw new Exception("Duplicate checker has wrong cardinality");
}
else if (duplicateChecker.nextClearBit(0) != numElementsTotal) {
throw new Exception("Received sparse sequence");
}
else {
throw new SuccessException();
}
}
}
代码示例来源:origin: com.h2database/h2
/**
* Begin a new transaction.
*
* @return the transaction
*/
public synchronized Transaction begin() {
int transactionId;
int status;
if (!init) {
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_TRANSACTION_ILLEGAL_STATE,
"Not initialized");
}
transactionId = openTransactions.nextClearBit(1);
if (transactionId > maxTransactionId) {
throw DataUtils.newIllegalStateException(
DataUtils.ERROR_TOO_MANY_OPEN_TRANSACTIONS,
"There are {0} open transactions",
transactionId - 1);
}
openTransactions.set(transactionId);
status = Transaction.STATUS_OPEN;
return new Transaction(this, transactionId, status, null, 0);
}
代码示例来源:origin: apache/flink
@Override
public void flatMap(Tuple2<Integer, Integer> value, Collector<Integer> out) throws Exception {
int partition = value.f0;
int val = value.f1;
BitSet bitSet = partitionsToValueCheck.get(partition);
if (bitSet == null) {
throw new RuntimeException("Got a record from an unknown partition");
} else {
bitSet.set(val - partitionsToValuesCountAndStartOffset.get(partition).f1);
}
count++;
LOG.info("Received message {}, total {} messages", value, count);
// verify if we've seen everything
if (count == finalCount) {
for (Map.Entry<Integer, BitSet> partitionsToValueCheck : this.partitionsToValueCheck.entrySet()) {
BitSet check = partitionsToValueCheck.getValue();
int expectedValueCount = partitionsToValuesCountAndStartOffset.get(partitionsToValueCheck.getKey()).f0;
if (check.cardinality() != expectedValueCount) {
throw new RuntimeException("Expected cardinality to be " + expectedValueCount +
", but was " + check.cardinality());
} else if (check.nextClearBit(0) != expectedValueCount) {
throw new RuntimeException("Expected next clear bit to be " + expectedValueCount +
", but was " + check.cardinality());
}
}
// test has passed
throw new SuccessException();
}
}
代码示例来源:origin: apache/flink
@Override
public void invoke(Tuple2<Long, String> value) throws Exception {
String[] sp = value.f1.split("-");
int v = Integer.parseInt(sp[1]);
assertEquals(value.f0 - 1000, (long) v);
assertFalse("Received tuple twice", validator.get(v));
validator.set(v);
elCnt++;
if (elCnt == totalElements) {
// check if everything in the bitset is set to true
int nc;
if ((nc = validator.nextClearBit(0)) != totalElements) {
fail("The bitset was not set to 1 on all elements. Next clear:"
+ nc + " Set: " + validator);
}
throw new SuccessException();
}
}
代码示例来源:origin: googleapis/google-cloud-java
private void fetchAndValidateRows(
List<Partition> partitions, BatchTransactionId txnID, BitSet seenRows) {
for (Partition p : partitions) {
BatchReadOnlyTransaction batchTxnOnEachWorker = client.batchReadOnlyTransaction(txnID);
try (ResultSet result = batchTxnOnEachWorker.execute(p)) {
// validate no duplicate rows; verify all columns read.
validate(result, seenRows);
}
}
// verify all rows were read from the database.
assertThat(seenRows.nextClearBit(0)).isEqualTo(numRows);
}
代码示例来源:origin: redisson/redisson
for (int ix = 0; (ix = _paramsSeenBig.nextClearBit(ix)) < len; ++ix) {
_creatorParameters[ix] = _findMissing(props[ix]);
代码示例来源:origin: prestodb/presto
for (int ix = 0; (ix = _paramsSeenBig.nextClearBit(ix)) < len; ++ix) {
_creatorParameters[ix] = _findMissing(props[ix]);
内容来源于网络,如有侵权,请联系作者删除!