本文整理汇总了Java中java.util.BitSet.nextClearBit方法的典型用法代码示例。如果您正苦于以下问题:Java BitSet.nextClearBit方法的具体用法?Java BitSet.nextClearBit怎么用?Java BitSet.nextClearBit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.BitSet
的用法示例。
在下文中一共展示了BitSet.nextClearBit方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import java.util.BitSet; //导入方法依赖的package包/类
public synchronized void initialize()
{
try
{
_freeIds = new BitSet(PrimeFinder.nextPrime(100000));
_freeIds.clear();
_freeIdCount = new AtomicInteger(FREE_OBJECT_ID_SIZE);
for (int usedObjectId : extractUsedObjectIDTable())
{
int objectID = usedObjectId - FIRST_OID;
if (objectID < 0)
{
_log.warning("Object ID " + usedObjectId + " in DB is less than minimum ID of " + FIRST_OID);
continue;
}
_freeIds.set(usedObjectId - FIRST_OID);
_freeIdCount.decrementAndGet();
}
_nextFreeId = new AtomicInteger(_freeIds.nextClearBit(0));
_initialized = true;
}
catch (Exception e)
{
_initialized = false;
_log.severe("BitSet ID Factory could not be initialized correctly");
e.printStackTrace();
}
}
示例2: removeAll
import java.util.BitSet; //导入方法依赖的package包/类
/**
* Removes multiple array elements specified by indices.
*
* @param <T> the type of array eg:String[]
* @param array source
* @param indices to remove
* @return new array of same type minus elements specified by the set bits in {@code indices}
*/
// package protected for access by unit tests
static <T> T removeAll(final T array, final BitSet indices) {
final int srcLength = Array.getLength(array);
// No need to check maxIndex here, because method only currently called from removeElements()
// which guarantee to generate on;y valid bit entries.
// final int maxIndex = indices.length();
// if (maxIndex > srcLength) {
// throw new IndexOutOfBoundsException("Index: " + (maxIndex-1) + ", Length: " + srcLength);
// }
final int removals = indices.cardinality(); // true bits are items to remove
final T result = (T) Array.newInstance(array.getClass().getComponentType(), srcLength - removals);
int srcIndex = 0;
int destIndex = 0;
int count;
int set;
while ((set = indices.nextSetBit(srcIndex)) != -1) {
count = set - srcIndex;
if (count > 0) {
System.arraycopy(array, srcIndex, result, destIndex, count);
destIndex += count;
}
srcIndex = indices.nextClearBit(set);
}
count = srcLength - srcIndex;
if (count > 0) {
System.arraycopy(array, srcIndex, result, destIndex, count);
}
return result;
}
示例3: nextClearBit
import java.util.BitSet; //导入方法依赖的package包/类
@Override
int nextClearBit(BitSet bitSet, int startIdx) {
int bitNumber = bitSet.nextClearBit(startIdx);
while (!isEven(bitNumber)) {
bitNumber = bitSet.nextClearBit(bitNumber + 1);
}
return bitNumber;
}
示例4: initialize
import java.util.BitSet; //导入方法依赖的package包/类
public void initialize()
{
try
{
_freeIds = new BitSet(PrimeFinder.nextPrime(100000));
_freeIds.clear();
_freeIdCount = new AtomicInteger(FREE_OBJECT_ID_SIZE);
for (int usedObjectId : extractUsedObjectIDTable())
{
final int objectID = usedObjectId - FIRST_OID;
if (objectID < 0)
{
LOGGER.warning(getClass().getSimpleName() + ": Object ID " + usedObjectId + " in DB is less than minimum ID of " + FIRST_OID);
continue;
}
_freeIds.set(usedObjectId - FIRST_OID);
_freeIdCount.decrementAndGet();
}
_nextFreeId = new AtomicInteger(_freeIds.nextClearBit(0));
_initialized = true;
}
catch (Exception e)
{
_initialized = false;
LOGGER.severe(getClass().getSimpleName() + ": Could not be initialized properly: " + e.getMessage());
}
}
示例5: getFreeRegister
import java.util.BitSet; //导入方法依赖的package包/类
public static int getFreeRegister(BlockNode node, MethodLocation index) {
List<MethodLocation> insns = node.getInstructions();
BitSet use = (BitSet)node.getOutSet().clone();
for (int i = insns.size()-1; i >= 0; i--) {
MethodLocation location = insns.get(i);
if (location.getIndex() < index.getIndex())
break; //we can stop here
Instruction insn = location.getInstruction();
if (insn == null)
continue;
if (insn.getOpcode().setsRegister()) {
int registernum = ((OneRegisterInstruction)insn).getRegisterA();
if (!use.get(registernum) //if we find it that the var will never be used afterwards
|| (insn.getOpcode().setsWideRegister() && !use.get(registernum+1))) {
location.setInstruction(null);
continue;
}
use.clear(registernum);
if (insn.getOpcode().setsWideRegister())
use.clear(registernum+1);
LiveVarVisitor.setUse(insn, use);
} else {
LiveVarVisitor.setUse(insn, use);
}
}
return use.nextClearBit(0);
}
示例6: accessBlank
import java.util.BitSet; //导入方法依赖的package包/类
/**
* 寻找一个或多个连续false
*
* @param bitSet
*/
public static void accessBlank(int size, BitSet bitSet, BiConsumer<Integer, Integer> consumer) {
int flag = bitSet.nextClearBit(0);
while (flag < size) {
int len = 1;
while (flag + len < size && !bitSet.get(flag + len)) {
len++;
}
consumer.accept(flag, len);
flag = bitSet.nextClearBit(flag + len);
}
}
示例7: formatName
import java.util.BitSet; //导入方法依赖的package包/类
@NonNull
public String formatName(
@NonNull final String name,
@NonNull final String textToFind,
final boolean caseSensitive) {
if (null == textToFind || "".equals(textToFind)) {
return name;
}
BitSet bitSet = new BitSet(name.length());
List<String> parts = splitByCamelCaseAndWildcards(textToFind);
String convertedTypeName = caseSensitive ? name : name.toLowerCase();
//mark the chars to be highlighted
int startIndex = 0;
for (String camelCasePart : parts) {
int indexOf = convertedTypeName.indexOf(caseSensitive ? camelCasePart : camelCasePart.toLowerCase(), startIndex);
if (indexOf != -1) {
//mark the chars
bitSet.set(indexOf, indexOf + camelCasePart.length(), true);
} else {
break;
}
startIndex = indexOf + camelCasePart.length();
}
//highlight the marked chars via tags
StringBuilder formattedTypeName = new StringBuilder();
int i = 0;
while (i < name.length()) {
boolean isMarked = bitSet.get(i);
if (isMarked) {
int numberOfContinuousHighlights = bitSet.nextClearBit(i) - i;
String part = name.substring(i, i + numberOfContinuousHighlights);
formattedTypeName.append(String.format(formatPattern, part));
i += numberOfContinuousHighlights;
} else {
formattedTypeName.append(name.charAt(i));
i++;
}
}
return formattedTypeName.toString();
}
示例8: func_181674_a
import java.util.BitSet; //导入方法依赖的package包/类
public void func_181674_a(float p_181674_1_, float p_181674_2_, float p_181674_3_)
{
int i = this.vertexCount / 4;
final float[] afloat = new float[i];
for (int j = 0; j < i; ++j)
{
afloat[j] = func_181665_a(this.rawFloatBuffer, (float)((double)p_181674_1_ + this.xOffset), (float)((double)p_181674_2_ + this.yOffset), (float)((double)p_181674_3_ + this.zOffset), this.vertexFormat.func_181719_f(), j * this.vertexFormat.getNextOffset());
}
Integer[] ainteger = new Integer[i];
for (int k = 0; k < ainteger.length; ++k)
{
ainteger[k] = Integer.valueOf(k);
}
Arrays.sort(ainteger, new Comparator<Integer>()
{
public int compare(Integer p_compare_1_, Integer p_compare_2_)
{
return Floats.compare(afloat[p_compare_2_.intValue()], afloat[p_compare_1_.intValue()]);
}
});
BitSet bitset = new BitSet();
int l = this.vertexFormat.getNextOffset();
int[] aint = new int[l];
for (int l1 = 0; (l1 = bitset.nextClearBit(l1)) < ainteger.length; ++l1)
{
int i1 = ainteger[l1].intValue();
if (i1 != l1)
{
this.rawIntBuffer.limit(i1 * l + l);
this.rawIntBuffer.position(i1 * l);
this.rawIntBuffer.get(aint);
int j1 = i1;
for (int k1 = ainteger[i1].intValue(); j1 != l1; k1 = ainteger[k1].intValue())
{
this.rawIntBuffer.limit(k1 * l + l);
this.rawIntBuffer.position(k1 * l);
IntBuffer intbuffer = this.rawIntBuffer.slice();
this.rawIntBuffer.limit(j1 * l + l);
this.rawIntBuffer.position(j1 * l);
this.rawIntBuffer.put(intbuffer);
bitset.set(j1);
j1 = k1;
}
this.rawIntBuffer.limit(l1 * l + l);
this.rawIntBuffer.position(l1 * l);
this.rawIntBuffer.put(aint);
}
bitset.set(l1);
}
}
示例9: func_181674_a
import java.util.BitSet; //导入方法依赖的package包/类
public void func_181674_a(float p_181674_1_, float p_181674_2_, float p_181674_3_)
{
int i = this.vertexCount / 4;
float[] afloat = new float[i];
for (int j = 0; j < i; ++j)
{
afloat[j] = func_181665_a(this.rawFloatBuffer, (float)((double)p_181674_1_ + this.xOffset), (float)((double)p_181674_2_ + this.yOffset), (float)((double)p_181674_3_ + this.zOffset), this.vertexFormat.func_181719_f(), j * this.vertexFormat.getNextOffset());
}
Integer[] ainteger = new Integer[i];
for (int k = 0; k < ainteger.length; ++k)
{
ainteger[k] = Integer.valueOf(k);
}
Arrays.sort(ainteger, new WorldRenderer$1(this, afloat));
BitSet bitset = new BitSet();
int l = this.vertexFormat.getNextOffset();
int[] aint = new int[l];
for (int l1 = 0; (l1 = bitset.nextClearBit(l1)) < ainteger.length; ++l1)
{
int i1 = ainteger[l1].intValue();
if (i1 != l1)
{
this.rawIntBuffer.limit(i1 * l + l);
this.rawIntBuffer.position(i1 * l);
this.rawIntBuffer.get(aint);
int j1 = i1;
for (int k1 = ainteger[i1].intValue(); j1 != l1; k1 = ainteger[k1].intValue())
{
this.rawIntBuffer.limit(k1 * l + l);
this.rawIntBuffer.position(k1 * l);
IntBuffer intbuffer = this.rawIntBuffer.slice();
this.rawIntBuffer.limit(j1 * l + l);
this.rawIntBuffer.position(j1 * l);
this.rawIntBuffer.put(intbuffer);
bitset.set(j1);
j1 = k1;
}
this.rawIntBuffer.limit(l1 * l + l);
this.rawIntBuffer.position(l1 * l);
this.rawIntBuffer.put(aint);
}
bitset.set(l1);
}
this.rawIntBuffer.limit(this.rawIntBuffer.capacity());
this.rawIntBuffer.position(this.func_181664_j());
if (this.quadSprites != null)
{
TextureAtlasSprite[] atextureatlassprite = new TextureAtlasSprite[this.vertexCount / 4];
int i2 = this.vertexFormat.func_181719_f() / 4 * 4;
for (int j2 = 0; j2 < ainteger.length; ++j2)
{
int k2 = ainteger[j2].intValue();
atextureatlassprite[j2] = this.quadSprites[k2];
}
System.arraycopy(atextureatlassprite, 0, this.quadSprites, 0, atextureatlassprite.length);
}
}
示例10: func_181674_a
import java.util.BitSet; //导入方法依赖的package包/类
public void func_181674_a(float p_181674_1_, float p_181674_2_, float p_181674_3_)
{
int i = this.vertexCount / 4;
float[] afloat = new float[i];
for (int j = 0; j < i; ++j)
{
afloat[j] = func_181665_a(this.rawFloatBuffer, (float)((double)p_181674_1_ + this.xOffset), (float)((double)p_181674_2_ + this.yOffset), (float)((double)p_181674_3_ + this.zOffset), this.vertexFormat.func_181719_f(), j * this.vertexFormat.getNextOffset());
}
Integer[] ainteger = new Integer[i];
for (int k = 0; k < ainteger.length; ++k)
{
ainteger[k] = Integer.valueOf(k);
}
Arrays.sort(ainteger, new WorldRenderer$1(this, afloat));
BitSet bitset = new BitSet();
int l = this.vertexFormat.getNextOffset();
int[] aint = new int[l];
for (int l1 = 0; (l1 = bitset.nextClearBit(l1)) < ainteger.length; ++l1)
{
int i1 = ainteger[l1].intValue();
if (i1 != l1)
{
this.rawIntBuffer.limit(i1 * l + l);
this.rawIntBuffer.position(i1 * l);
this.rawIntBuffer.get(aint);
int j1 = i1;
for (int k1 = ainteger[i1].intValue(); j1 != l1; k1 = ainteger[k1].intValue())
{
this.rawIntBuffer.limit(k1 * l + l);
this.rawIntBuffer.position(k1 * l);
IntBuffer intbuffer = this.rawIntBuffer.slice();
this.rawIntBuffer.limit(j1 * l + l);
this.rawIntBuffer.position(j1 * l);
this.rawIntBuffer.put(intbuffer);
bitset.set(j1);
j1 = k1;
}
this.rawIntBuffer.limit(l1 * l + l);
this.rawIntBuffer.position(l1 * l);
this.rawIntBuffer.put(aint);
}
bitset.set(l1);
}
if (this.quadSprites != null)
{
TextureAtlasSprite[] atextureatlassprite = new TextureAtlasSprite[this.vertexCount / 4];
int i2 = this.vertexFormat.func_181719_f() / 4 * 4;
for (int j2 = 0; j2 < ainteger.length; ++j2)
{
int k2 = ainteger[j2].intValue();
atextureatlassprite[j2] = this.quadSprites[k2];
}
System.arraycopy(atextureatlassprite, 0, this.quadSprites, 0, atextureatlassprite.length);
}
}
示例11: sortVertexData
import java.util.BitSet; //导入方法依赖的package包/类
public void sortVertexData(float p_181674_1_, float p_181674_2_, float p_181674_3_)
{
int i = this.vertexCount / 4;
final float[] afloat = new float[i];
for (int j = 0; j < i; ++j)
{
afloat[j] = getDistanceSq(this.rawFloatBuffer, (float)((double)p_181674_1_ + this.xOffset), (float)((double)p_181674_2_ + this.yOffset), (float)((double)p_181674_3_ + this.zOffset), this.vertexFormat.getIntegerSize(), j * this.vertexFormat.getNextOffset());
}
Integer[] ainteger = new Integer[i];
for (int k = 0; k < ainteger.length; ++k)
{
ainteger[k] = Integer.valueOf(k);
}
Arrays.sort(ainteger, new Comparator<Integer>()
{
public int compare(Integer p_compare_1_, Integer p_compare_2_)
{
return Floats.compare(afloat[p_compare_2_.intValue()], afloat[p_compare_1_.intValue()]);
}
});
BitSet bitset = new BitSet();
int l = this.vertexFormat.getNextOffset();
int[] aint = new int[l];
for (int i1 = bitset.nextClearBit(0); i1 < ainteger.length; i1 = bitset.nextClearBit(i1 + 1))
{
int j1 = ainteger[i1].intValue();
if (j1 != i1)
{
this.rawIntBuffer.limit(j1 * l + l);
this.rawIntBuffer.position(j1 * l);
this.rawIntBuffer.get(aint);
int k1 = j1;
for (int l1 = ainteger[j1].intValue(); k1 != i1; l1 = ainteger[l1].intValue())
{
this.rawIntBuffer.limit(l1 * l + l);
this.rawIntBuffer.position(l1 * l);
IntBuffer intbuffer = this.rawIntBuffer.slice();
this.rawIntBuffer.limit(k1 * l + l);
this.rawIntBuffer.position(k1 * l);
this.rawIntBuffer.put(intbuffer);
bitset.set(k1);
k1 = l1;
}
this.rawIntBuffer.limit(i1 * l + l);
this.rawIntBuffer.position(i1 * l);
this.rawIntBuffer.put(aint);
}
bitset.set(i1);
}
this.rawIntBuffer.limit(this.rawIntBuffer.capacity());
this.rawIntBuffer.position(this.getBufferSize());
if (this.quadSprites != null)
{
TextureAtlasSprite[] atextureatlassprite = new TextureAtlasSprite[this.vertexCount / 4];
int i2 = this.vertexFormat.getNextOffset() / 4 * 4;
for (int j2 = 0; j2 < ainteger.length; ++j2)
{
int k2 = ainteger[j2].intValue();
atextureatlassprite[j2] = this.quadSprites[k2];
}
System.arraycopy(atextureatlassprite, 0, this.quadSprites, 0, atextureatlassprite.length);
}
}
示例12: projectBuildNonMatches
import java.util.BitSet; //导入方法依赖的package包/类
/**
* Project any remaining build items that were not matched. Only used when doing a FULL or RIGHT join.
* @return Negative output if records were output but batch wasn't completed. Positive output if batch was completed.
*/
public int projectBuildNonMatches() {
assert projectUnmatchedBuild;
projectBuildNonMatchesWatch.start();
final int targetRecordsPerBatch = this.targetRecordsPerBatch;
int outputRecords = 0;
int remainderBuildSetIndex = this.remainderBuildSetIndex;
int nextClearIndex = remainderBuildElementIndex;
BitSet currentBitset = remainderBuildSetIndex < 0 ? null : matches[remainderBuildSetIndex];
final long projectBuildOffsetAddr = this.projectBuildOffsetAddr;
// determine the next set of unmatched bits.
while(outputRecords < targetRecordsPerBatch) {
if(nextClearIndex == -1){
// we need to move to the next bit set since the current one has no more matches.
remainderBuildSetIndex++;
if (remainderBuildSetIndex < matches.length) {
currentBitset = matches[remainderBuildSetIndex];
nextClearIndex = 0;
} else {
// no bitsets left.
this.remainderBuildSetIndex = matches.length;
remainderBuildSetIndex = -1;
break;
}
}
nextClearIndex = currentBitset.nextClearBit(nextClearIndex);
if(nextClearIndex != -1){
// the clear bit is only valid if it is within the batch it corresponds to.
if(nextClearIndex >= matchMaxes[remainderBuildSetIndex]){
nextClearIndex = -1;
}else{
final long projectBuildOffsetAddrStart = projectBuildOffsetAddr + outputRecords * BUILD_RECORD_LINK_SIZE;
PlatformDependent.putInt(projectBuildOffsetAddrStart, remainderBuildSetIndex);
PlatformDependent.putShort(projectBuildOffsetAddrStart + 4, (short)(nextClearIndex & HashTable.BATCH_MASK));
outputRecords++;
nextClearIndex++;
}
}
}
projectBuildNonMatchesWatch.stop();
allocateOnlyProbe(outputRecords);
projectBuild(projectBuildOffsetAddr, outputRecords);
this.remainderBuildSetIndex = remainderBuildSetIndex;
this.remainderBuildElementIndex = nextClearIndex;
if(remainderBuildElementIndex == -1){
return outputRecords;
} else {
return -outputRecords;
}
}
示例13: projectBuildNonMatches
import java.util.BitSet; //导入方法依赖的package包/类
/**
* Project any remaining build items that were not matched. Only used when doing a FULL or RIGHT join.
* @return Negative output if records were output but batch wasn't completed. Positive output if batch was completed.
*/
@Override
public int projectBuildNonMatches() {
assert projectUnmatchedBuild;
final int targetRecordsPerBatch = this.targetRecordsPerBatch;
int outputRecords = 0;
int remainderBuildSetIndex = this.remainderBuildSetIndex;
BitSet currentBitset = remainderBuildSetIndex < 0 ? null : matches[remainderBuildSetIndex];
int nextClearIndex = remainderBuildElementIndex;
while(outputRecords < targetRecordsPerBatch) {
if(nextClearIndex == -1){
// we need to move to the next bit set since the current one has no more matches.
remainderBuildSetIndex++;
if (remainderBuildSetIndex < matches.length) {
currentBitset = matches[remainderBuildSetIndex];
nextClearIndex = 0;
} else {
// no bitsets left.
this.remainderBuildSetIndex = matches.length;
this.remainderBuildElementIndex = -1;
return outputRecords;
}
}
nextClearIndex = currentBitset.nextClearBit(nextClearIndex);
if(nextClearIndex != -1){
// the clear bit is only valid if it is within the batch it corresponds to.
if(nextClearIndex >= matchMaxes[remainderBuildSetIndex]){
nextClearIndex = -1;
}else{
int composite = (remainderBuildSetIndex << SHIFT_SIZE) | (nextClearIndex & HashTable.BATCH_MASK);
projectBuildRecord(composite, outputRecords);
outputRecords++;
nextClearIndex++;
}
}
}
this.remainderBuildSetIndex = remainderBuildSetIndex;
this.remainderBuildElementIndex = nextClearIndex;
return -outputRecords;
}
示例14: sortVertexData
import java.util.BitSet; //导入方法依赖的package包/类
public void sortVertexData(float p_181674_1_, float p_181674_2_, float p_181674_3_)
{
int i = this.vertexCount / 4;
final float[] afloat = new float[i];
for (int j = 0; j < i; ++j)
{
afloat[j] = getDistanceSq(this.rawFloatBuffer, (float)((double)p_181674_1_ + this.xOffset), (float)((double)p_181674_2_ + this.yOffset), (float)((double)p_181674_3_ + this.zOffset), this.vertexFormat.getIntegerSize(), j * this.vertexFormat.getNextOffset());
}
Integer[] ainteger = new Integer[i];
for (int k = 0; k < ainteger.length; ++k)
{
ainteger[k] = Integer.valueOf(k);
}
Arrays.sort(ainteger, new Comparator<Integer>()
{
public int compare(Integer p_compare_1_, Integer p_compare_2_)
{
return Floats.compare(afloat[p_compare_2_.intValue()], afloat[p_compare_1_.intValue()]);
}
});
BitSet bitset = new BitSet();
int l = this.vertexFormat.getNextOffset();
int[] aint = new int[l];
for (int i1 = bitset.nextClearBit(0); i1 < ainteger.length; i1 = bitset.nextClearBit(i1 + 1))
{
int j1 = ainteger[i1].intValue();
if (j1 != i1)
{
this.rawIntBuffer.limit(j1 * l + l);
this.rawIntBuffer.position(j1 * l);
this.rawIntBuffer.get(aint);
int k1 = j1;
for (int l1 = ainteger[j1].intValue(); k1 != i1; l1 = ainteger[l1].intValue())
{
this.rawIntBuffer.limit(l1 * l + l);
this.rawIntBuffer.position(l1 * l);
IntBuffer intbuffer = this.rawIntBuffer.slice();
this.rawIntBuffer.limit(k1 * l + l);
this.rawIntBuffer.position(k1 * l);
this.rawIntBuffer.put(intbuffer);
bitset.set(k1);
k1 = l1;
}
this.rawIntBuffer.limit(i1 * l + l);
this.rawIntBuffer.position(i1 * l);
this.rawIntBuffer.put(aint);
}
bitset.set(i1);
}
this.rawIntBuffer.limit(this.rawIntBuffer.capacity());
this.rawIntBuffer.position(this.getBufferSize());
}