use of it.unimi.dsi.fastutil.longs.LongIterator in project geode by apache.
the class DiskInitFile method saveCrfIds.
private void saveCrfIds() {
for (LongIterator i = this.crfIds.iterator(); i.hasNext(); ) {
writeIFRecord(IFREC_CRF_CREATE, i.next());
this.ifLiveRecordCount++;
this.ifTotalRecordCount++;
}
}
use of it.unimi.dsi.fastutil.longs.LongIterator in project Nukkit by Nukkit.
the class Player method orderChunks.
protected boolean orderChunks() {
if (!this.connected) {
return false;
}
Timings.playerChunkOrderTimer.startTiming();
this.nextChunkOrderRun = 200;
loadQueue.clear();
Long2ObjectOpenHashMap<Boolean> lastChunk = new Long2ObjectOpenHashMap<>(this.usedChunks);
int centerX = (int) this.x >> 4;
int centerZ = (int) this.z >> 4;
int radius = spawned ? this.chunkRadius : (int) Math.ceil(Math.sqrt(spawnThreshold));
int radiusSqr = radius * radius;
long index;
for (int x = 0; x <= radius; x++) {
int xx = x * x;
for (int z = 0; z <= x; z++) {
int distanceSqr = xx + z * z;
if (distanceSqr > radiusSqr)
continue;
/* Top right quadrant */
if (this.usedChunks.get(index = Level.chunkHash(centerX + x, centerZ + z)) != Boolean.TRUE) {
this.loadQueue.put(index, Boolean.TRUE);
}
lastChunk.remove(index);
/* Top left quadrant */
if (this.usedChunks.get(index = Level.chunkHash(centerX - x - 1, centerZ + z)) != Boolean.TRUE) {
this.loadQueue.put(index, Boolean.TRUE);
}
lastChunk.remove(index);
/* Bottom right quadrant */
if (this.usedChunks.get(index = Level.chunkHash(centerX + x, centerZ - z - 1)) != Boolean.TRUE) {
this.loadQueue.put(index, Boolean.TRUE);
}
lastChunk.remove(index);
/* Bottom left quadrant */
if (this.usedChunks.get(index = Level.chunkHash(centerX - x - 1, centerZ - z - 1)) != Boolean.TRUE) {
this.loadQueue.put(index, Boolean.TRUE);
}
lastChunk.remove(index);
if (x != z) {
/* Top right quadrant mirror */
if (this.usedChunks.get(index = Level.chunkHash(centerX + z, centerZ + x)) != Boolean.TRUE) {
this.loadQueue.put(index, Boolean.TRUE);
}
lastChunk.remove(index);
/* Top left quadrant mirror */
if (this.usedChunks.get(index = Level.chunkHash(centerX - z - 1, centerZ + x)) != Boolean.TRUE) {
this.loadQueue.put(index, Boolean.TRUE);
}
lastChunk.remove(index);
/* Bottom right quadrant mirror */
if (this.usedChunks.get(index = Level.chunkHash(centerX + z, centerZ - x - 1)) != Boolean.TRUE) {
this.loadQueue.put(index, Boolean.TRUE);
}
lastChunk.remove(index);
/* Bottom left quadrant mirror */
if (this.usedChunks.get(index = Level.chunkHash(centerX - z - 1, centerZ - x - 1)) != Boolean.TRUE) {
this.loadQueue.put(index, Boolean.TRUE);
}
lastChunk.remove(index);
}
}
}
LongIterator keys = lastChunk.keySet().iterator();
while (keys.hasNext()) {
index = keys.nextLong();
this.unloadChunk(Level.getHashX(index), Level.getHashZ(index));
}
Timings.playerChunkOrderTimer.stopTiming();
return true;
}
use of it.unimi.dsi.fastutil.longs.LongIterator in project presto by prestodb.
the class KHyperLogLog method jaccardIndex.
public static double jaccardIndex(KHyperLogLog a, KHyperLogLog b) {
int sizeOfSmallerSet = Math.min(a.minhash.size(), b.minhash.size());
LongSortedSet minUnion = new LongRBTreeSet(a.minhash.keySet());
minUnion.addAll(b.minhash.keySet());
int intersection = 0;
int i = 0;
LongIterator iterator = minUnion.iterator();
while (iterator.hasNext()) {
long key = iterator.nextLong();
if (a.minhash.containsKey(key) && b.minhash.containsKey(key)) {
intersection++;
}
i++;
if (i >= sizeOfSmallerSet) {
break;
}
}
return intersection / (double) sizeOfSmallerSet;
}
use of it.unimi.dsi.fastutil.longs.LongIterator in project symja_android_library by axkr.
the class InstantColumn method removeMissing.
@Override
public InstantColumn removeMissing() {
InstantColumn noMissing = emptyCopy();
LongIterator iterator = longIterator();
while (iterator.hasNext()) {
long i = iterator.nextLong();
if (!valueIsMissing(i)) {
noMissing.appendInternal(i);
}
}
return noMissing;
}
use of it.unimi.dsi.fastutil.longs.LongIterator in project angel by Tencent.
the class IntLongVector method max.
public long max() {
IntLongVectorStorage idstorage = (IntLongVectorStorage) storage;
if (idstorage.size() == 0)
return 0;
long maxval = Long.MIN_VALUE;
if (idstorage.isSparse()) {
LongIterator iter = idstorage.valueIterator();
while (iter.hasNext()) {
long val = iter.nextLong();
if (val > maxval) {
maxval = val;
}
}
} else {
for (long val : idstorage.getValues()) {
if (val > maxval) {
maxval = val;
}
}
}
return maxval;
}
Aggregations