ReceivedVersionsReverseIteratorB() { this.index = -1; if (received == null) { nextIndex = -1; } else { this.nextIndex = received.previousSetBit((int) (nextVersion - receivedBaseVersion - 1)); if (nextIndex + receivedBaseVersion <= previousVersion) { nextIndex = -1; } } }
@Override long next() { this.index = this.nextIndex; if (this.index < 0) { throw new NoSuchElementException("no more elements available"); } this.nextIndex = received.previousSetBit(this.index - 1); if (nextIndex + receivedBaseVersion <= previousVersion) { nextIndex = -1; } return this.index + receivedBaseVersion; }
/** * Get the position of the last (infinite) free space. * * @return the position. */ public long getLastFree() { return getPos(set.previousSetBit(set.size()-1) + 1); }
@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; } }
int lastValidIndex = selectedBitSet.previousSetBit(size - 1); RecordIdentifier lastRecordIdInBatch = new RecordIdentifier(
int lastValidIndex = selectedBitSet.previousSetBit(batch.size - 1); RecordIdentifier lastRecordIdInBatch = new RecordIdentifier(
public int previousSetBit(int i) {return myBits.previousSetBit(i);} public int previousClearBit(int i) {return myBits.previousClearBit(i);}
@Override public Integer next() { if (myNext == -1) { throw new NoSuchElementException(); } myLast = myNext; myNext = myIsReversed ? (myNext == 0 ? -1 : myBitSet.previousSetBit(myNext - 1)) : myBitSet.nextSetBit(myNext + 1); return myLast; }
public BitSetIterator(BitSet bitSet, boolean reversed) { myBitSet = bitSet; myIsReversed = reversed; myNext = reversed ? bitSet.previousSetBit(bitSet.length()) : bitSet.nextSetBit(0); myLast = -1; }
public int cardinality(int start, int end) { int count = 0; if (start >= 0 && end > 0 && start < end) { int firstBit = myBits.nextSetBit(0); int lastBit = myBits.previousSetBit(myBits.length()) + 1; if (start < firstBit) start = firstBit; if (end > lastBit) end = lastBit; if (start <= end && myBits.length() > 0) { int startIndex = start >> 6; int endIndex = end >> 6; long startMask = -1L << (start & 63); // 0-FF, 1-FE, 2-FC, 3-FE, 4-F0.... long endMask = ~(-1L << (end & 63)); // 0-0, 1-01, 2-03, 3-07 if (endMask == 0) { endIndex--; endMask = -1L; } long[] words = myBits.toLongArray(); for (int i = startIndex; i <= endIndex; i++) { long word = words[i]; if (i == startIndex) word &= startMask; if (i == endIndex) word &= endMask; count += Long.bitCount(word); } } } return count; }
boolean changed = false; while (index-- > 0) { index = removeSet.previousSetBit(index); if (index == -1) break; remove(myValueList.get(index));
private boolean updateMaxBidPriceHot(int idx) { int nextIdx = hotBidBitSet.previousSetBit(idx); if (nextIdx == -1) { // not found, have to also check far area return true; } // found new maxBidPrice in hot bitset maxBidPrice = nextIdx + basePrice; return false; }
/** * returns whether the last downward branching jump seen crosses over the current location * * @param pc * the current location * @return if the last if statement branched over here */ private boolean gotoAcrossPC(int pc) { int target = gotoBranchPCs.previousSetBit(Integer.MAX_VALUE); return (target > pc); }
public BitSetIterator(BitSet bitSet, boolean reversed) { myBitSet = bitSet; myIsReversed = reversed; myNext = reversed ? bitSet.previousSetBit(bitSet.length()) : bitSet.nextSetBit(0); myLast = -1; }
@Override public Integer next() { if (myNext == -1) { throw new NoSuchElementException(); } myLast = myNext; myNext = myIsReversed ? (myNext == 0 ? -1 : myBitSet.previousSetBit(myNext - 1)) : myBitSet.nextSetBit(myNext + 1); return myLast; }
@Override public int max() { if(isEmpty()) throw new IllegalStateException("cannot find maximum of an empty set"); return offset+values.previousSetBit(values.length()); }
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; }
/** * Get the position of the last (infinite) free space. * * @return the position. */ public long getLastFree() { return getPos(set.previousSetBit(set.size()-1) + 1); }
/** * Finds the start of the first statement boundary that is on or before {@code offset}. If one is not found, {@code -1} is returned. */ default int getPreviousStatement(int offset) { return getStatements().previousSetBit(offset); }
@SuppressWarnings("unchecked") @Override public PersistentLongMap.Entry<V> next() { if (!hasNext()) { throw new NoSuchElementException(); } final int index = this.next; final long key = index + currentEntryBase; final Object result = currentEntry.data[index]; this.next = currentEntry.bits.previousSetBit(index - 1); return new LongMapEntry<>(key, (V) result); }