it.unimi.dsi.fastutil.objects.ObjectIterator Java Examples
The following examples show how to use
it.unimi.dsi.fastutil.objects.ObjectIterator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DictionaryBasedGroupKeyGenerator.java From incubator-pinot with Apache License 2.0 | 6 votes |
@Nonnull @Override public Iterator<GroupKey> iterator() { return new Iterator<GroupKey>() { private final ObjectIterator<Int2IntMap.Entry> _iterator = _rawKeyToGroupIdMap.int2IntEntrySet().fastIterator(); private final GroupKey _groupKey = new GroupKey(); @Override public boolean hasNext() { return _iterator.hasNext(); } @Override public GroupKey next() { Int2IntMap.Entry entry = _iterator.next(); _groupKey._groupId = entry.getIntValue(); _groupKey._stringKey = getGroupKey(entry.getIntKey()); return _groupKey; } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
Example #2
Source File: BlockVectorSet.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
public Vector get(int index) { int count = 0; ObjectIterator<Int2ObjectMap.Entry<LocalBlockVectorSet>> iter = localSets.int2ObjectEntrySet().iterator(); while (iter.hasNext()) { Int2ObjectMap.Entry<LocalBlockVectorSet> entry = iter.next(); LocalBlockVectorSet set = entry.getValue(); int size = set.size(); int newSize = count + size; if (newSize > index) { int localIndex = index - count; Vector pos = set.getIndex(localIndex); if (pos != null) { int pair = entry.getIntKey(); int cx = MathMan.unpairX(pair); int cz = MathMan.unpairY(pair); pos.mutX((cx << 11) + pos.getBlockX()); pos.mutZ((cz << 11) + pos.getBlockZ()); return pos; } } count += newSize; } return null; }
Example #3
Source File: SchemVis.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
/** * Discard chunks outside FOV */ private void clean() { if (chunks.size() > 225) { TaskManager.IMP.sync(() -> { if (chunks.size() > 225) { synchronized (SchemVis.this) { FaweLocation pos = player.getLocation(); int centerX = pos.x >> 4; int centerZ = pos.z >> 4; ObjectIterator<Long2ObjectMap.Entry<MCAChunk>> iter = chunks.long2ObjectEntrySet().fastIterator(); while (iter.hasNext()) { Long2ObjectMap.Entry<MCAChunk> entry = iter.next(); long pair = entry.getLongKey(); int chunkX = MathMan.unpairIntX(pair); int chunkZ = MathMan.unpairIntY(pair); if (Math.abs(centerX - chunkX) > 15 || Math.abs(centerZ - chunkZ) > 15) { iter.remove(); } } } } return null; }); } }
Example #4
Source File: TeleporterPaths.java From TFC2 with GNU General Public License v3.0 | 6 votes |
/** * called periodically to remove out-of-date portal locations from the cache list. Argument par1 is a * WorldServer.getTotalWorldTime() value. */ @Override public void removeStalePortalLocations(long worldTime) { if (worldTime % 100L == 0L) { long i = worldTime - 600L; ObjectIterator<Teleporter.PortalPosition> objectiterator = this.destinationCoordinateCache.values().iterator(); while (objectiterator.hasNext()) { Teleporter.PortalPosition teleporter$portalposition = (Teleporter.PortalPosition)objectiterator.next(); if (teleporter$portalposition == null || teleporter$portalposition.lastUpdateTime < i) { objectiterator.remove(); } } } }
Example #5
Source File: LuceneLinkTokenizer.java From WikipediaEntities with GNU Affero General Public License v3.0 | 6 votes |
@Override public void close() { synchronized(LuceneLinkTokenizer.this) { Object2IntOpenHashMap<String> plinks = LuceneLinkTokenizer.this.links; if(plinks.size() == 0) { LuceneLinkTokenizer.this.links = links; } else { for(ObjectIterator<Object2IntOpenHashMap.Entry<String>> it = links.object2IntEntrySet().fastIterator(); it.hasNext();) { Object2IntOpenHashMap.Entry<String> ent = it.next(); plinks.addTo(ent.getKey(), ent.getIntValue()); } } links = null; } }
Example #6
Source File: LuceneLinkTokenizer.java From WikipediaEntities with GNU Affero General Public License v3.0 | 6 votes |
public void close() throws IOException { System.err.format("Closing %s output.\n", getClass().getSimpleName()); PrintStream writer = Util.openOutput(out); // We sort everything here. This is expensive, but makes the output // files nicer to use in the future. ArrayList<String> keys = new ArrayList<>(links.size()); for(ObjectIterator<Object2IntOpenHashMap.Entry<String>> it = links.object2IntEntrySet().fastIterator(); it.hasNext();) { Object2IntOpenHashMap.Entry<String> ent = it.next(); if(ent.getIntValue() >= MINSUPP) { keys.add(ent.getKey()); } } Collections.sort(keys); for(String key : keys) { writer.append(key); writer.append('\n'); } if(writer != System.out) writer.close(); }
Example #7
Source File: BukkitBridge.java From BungeeTabListPlus with GNU General Public License v3.0 | 6 votes |
@Override @Nullable Server getConnection() { synchronized (this) { ObjectIterator<Server> iterator = connections.iterator(); while (iterator.hasNext()) { Server server = iterator.next(); if (server.isConnected()) { return server; } else { iterator.remove(); } } return null; } }
Example #8
Source File: WorkbenchVirtualizer.java From BUbiNG with Apache License 2.0 | 6 votes |
private void writeMetadata(final ObjectOutputStream oos) throws IOException { oos.writeLong(byteArrayDiskQueues.size); oos.writeLong(byteArrayDiskQueues.appendPointer); oos.writeLong(byteArrayDiskQueues.used); oos.writeLong(byteArrayDiskQueues.allocated); oos.writeInt(byteArrayDiskQueues.buffers.size()); oos.writeInt(byteArrayDiskQueues.key2QueueData.size()); final ObjectIterator<Reference2ObjectMap.Entry<Object, QueueData>> fastIterator = byteArrayDiskQueues.key2QueueData.reference2ObjectEntrySet().fastIterator(); for(int i = byteArrayDiskQueues.key2QueueData.size(); i-- != 0;) { final Reference2ObjectMap.Entry<Object, QueueData> next = fastIterator.next(); final VisitState visitState = (VisitState)next.getKey(); // TODO: temporary, to catch serialization bug if (visitState == null) { LOGGER.error("Map iterator returned null key"); continue; } else if (visitState.schemeAuthority == null) LOGGER.error("Map iterator returned visit state with null schemeAuthority"); else Util.writeVByte(visitState.schemeAuthority.length, oos); oos.write(visitState.schemeAuthority); oos.writeObject(next.getValue()); } oos.close(); }
Example #9
Source File: Item.java From StreamingRec with Apache License 2.0 | 6 votes |
/** * Returns the item as a CSV line */ @Override public String toString() { String keywords = ""; //in case there are keywords -> serialize them if(this.keywords!=null){ StringBuilder sb = new StringBuilder(); ObjectIterator<Entry<String>> fastIterator = this.keywords.object2IntEntrySet().fastIterator(); while(fastIterator.hasNext()){ Entry<String> next = fastIterator.next(); sb.append(next.getKey().replace("-","").replace("#", "")); sb.append("-"); sb.append(next.getIntValue()); if(fastIterator.hasNext()){ sb.append("#"); } } keywords = sb.toString(); } //write CSV string return publisher + Constants.CSV_SEPARATOR + Constants.DATE_FORMAT.format(createdAt) + Constants.CSV_SEPARATOR + id + Constants.CSV_SEPARATOR + url + Constants.CSV_SEPARATOR + title + Constants.CSV_SEPARATOR + category + Constants.CSV_SEPARATOR + text + Constants.CSV_SEPARATOR + keywords; }
Example #10
Source File: Anvil.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void doGarbageCollection(long time) { long start = System.currentTimeMillis(); int maxIterations = size(); if (lastPosition > maxIterations) lastPosition = 0; int i; synchronized (chunks) { ObjectIterator<BaseFullChunk> iter = chunks.values().iterator(); if (lastPosition != 0) iter.skip(lastPosition); for (i = 0; i < maxIterations; i++) { if (!iter.hasNext()) { iter = chunks.values().iterator(); } if (!iter.hasNext()) break; BaseFullChunk chunk = iter.next(); if (chunk == null) continue; if (chunk.isGenerated() && chunk.isPopulated() && chunk instanceof Chunk) { Chunk anvilChunk = (Chunk) chunk; chunk.compress(); if (System.currentTimeMillis() - start >= time) break; } } } lastPosition += i; }
Example #11
Source File: BaseLevelProvider.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public synchronized void close() { this.unloadChunks(); synchronized (regions) { ObjectIterator<BaseRegionLoader> iter = this.regions.values().iterator(); while (iter.hasNext()) { try { iter.next().close(); } catch (IOException e) { throw new RuntimeException("Unable to close RegionLoader", e); } lastRegion.set(null); iter.remove(); } } this.level = null; }
Example #12
Source File: BaseLevelProvider.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public void doGarbageCollection() { int limit = (int) (System.currentTimeMillis() - 50); synchronized (regions) { if (regions.isEmpty()) { return; } ObjectIterator<BaseRegionLoader> iter = regions.values().iterator(); while (iter.hasNext()) { BaseRegionLoader loader = iter.next(); if (loader.lastUsed <= limit) { try { loader.close(); } catch (IOException e) { throw new RuntimeException("Unable to close RegionLoader", e); } lastRegion.set(null); iter.remove(); } } } }
Example #13
Source File: FastCollectionsUtils.java From fastjgame with Apache License 2.0 | 6 votes |
/** * 移除map中符合条件的元素,并对删除的元素执行后续的操作。 * * @param map 必须是可修改的map * @param predicate 过滤条件,为真的删除 * @param then 元素删除之后执行的逻辑 * @param <V> the type of value * @return 删除的元素数量 */ public static <V> int removeIfAndThen(final Long2ObjectMap<V> map, final LongObjPredicate<? super V> predicate, LongObjConsumer<V> then) { if (map.size() == 0) { return 0; } ObjectIterator<Long2ObjectMap.Entry<V>> itr = map.long2ObjectEntrySet().iterator(); int removeNum = 0; Long2ObjectMap.Entry<V> entry; long k; V v; while (itr.hasNext()) { entry = itr.next(); k = entry.getLongKey(); v = entry.getValue(); if (predicate.test(k, v)) { itr.remove(); removeNum++; then.accept(k, v); } } return removeNum; }
Example #14
Source File: LayeredLabelPropagation.java From fasten with Apache License 2.0 | 6 votes |
public Iterator<Int2IntMap.Entry> entries() { return new ObjectIterator<>() { private int i; private final Entry entry = new Entry(); @Override public boolean hasNext() { return i < n; } @Override public Entry next() { if (!hasNext()) throw new NoSuchElementException(); final int l = location[i++]; entry.setKey(key[l]); entry.setValue(count[l]); return entry; } }; }
Example #15
Source File: TofuTeleporter.java From TofuCraftReload with MIT License | 6 votes |
/** * called periodically to remove out-of-date portal locations from the cache list. Argument par1 is a * WorldServer.getTotalWorldTime() value. */ @Override public void removeStalePortalLocations(long worldTime) { if (worldTime % 100L == 0L) { long i = worldTime - 300L; ObjectIterator<PortalPosition> objectiterator = this.destinationCoordinateCache.values().iterator(); while (objectiterator.hasNext()) { PortalPosition teleporter$portalposition = (PortalPosition) objectiterator.next(); if (teleporter$portalposition == null || teleporter$portalposition.lastUpdateTime < i) { objectiterator.remove(); } } } }
Example #16
Source File: FastCollectionsUtils.java From fastjgame with Apache License 2.0 | 6 votes |
/** * 移除map中符合条件的元素,并对删除的元素执行后续的操作 * * @param map 必须是可修改的map * @param predicate 过滤条件,为真的删除 * @param then 元素删除之后执行的逻辑 * @param <V> the type of value * @return 删除的元素数量 */ public static <V> int removeIfAndThen(final Short2ObjectMap<V> map, final ShortObjPredicate<? super V> predicate, ShortObjConsumer<V> then) { if (map.size() == 0) { return 0; } ObjectIterator<Short2ObjectMap.Entry<V>> itr = map.short2ObjectEntrySet().iterator(); int removeNum = 0; Short2ObjectMap.Entry<V> entry; short k; V v; while (itr.hasNext()) { entry = itr.next(); k = entry.getShortKey(); v = entry.getValue(); if (predicate.test(k, v)) { itr.remove(); removeNum++; then.accept(k, v); } } return removeNum; }
Example #17
Source File: FastCollectionsUtils.java From fastjgame with Apache License 2.0 | 6 votes |
/** * 移除map中符合条件的元素,并对删除的元素执行后续的操作 * * @param map 必须是可修改的map * @param predicate 过滤条件,为真的删除 * @param then 元素删除之后执行的逻辑 * @param <V> the type of value * @return 删除的元素数量 */ public static <V> int removeIfAndThen(final Int2ObjectMap<V> map, final IntObjPredicate<? super V> predicate, IntObjConsumer<V> then) { if (map.size() == 0) { return 0; } ObjectIterator<Int2ObjectMap.Entry<V>> itr = map.int2ObjectEntrySet().iterator(); int removeNum = 0; Int2ObjectMap.Entry<V> entry; int k; V v; while (itr.hasNext()) { entry = itr.next(); k = entry.getIntKey(); v = entry.getValue(); if (predicate.test(k, v)) { itr.remove(); removeNum++; then.accept(k, v); } } return removeNum; }
Example #18
Source File: DictionaryBasedGroupKeyGenerator.java From incubator-pinot with Apache License 2.0 | 5 votes |
@Nonnull @Override public Iterator<GroupKey> iterator() { return new Iterator<GroupKey>() { private final ObjectIterator<Long2IntMap.Entry> _iterator = _rawKeyToGroupIdMap.long2IntEntrySet().fastIterator(); private final GroupKey _groupKey = new GroupKey(); @Override public boolean hasNext() { return _iterator.hasNext(); } @Override public GroupKey next() { Long2IntMap.Entry entry = _iterator.next(); _groupKey._groupId = entry.getIntValue(); _groupKey._stringKey = getGroupKey(entry.getLongKey()); return _groupKey; } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
Example #19
Source File: DictionaryBasedGroupKeyGenerator.java From incubator-pinot with Apache License 2.0 | 5 votes |
@Nonnull @Override public Iterator<GroupKey> iterator() { return new Iterator<GroupKey>() { private final ObjectIterator<Object2IntMap.Entry<IntArray>> _iterator = _rawKeyToGroupIdMap.object2IntEntrySet().fastIterator(); private final GroupKey _groupKey = new GroupKey(); @Override public boolean hasNext() { return _iterator.hasNext(); } @Override public GroupKey next() { Object2IntMap.Entry<IntArray> entry = _iterator.next(); _groupKey._groupId = entry.getIntValue(); _groupKey._stringKey = getGroupKey(entry.getKey()); return _groupKey; } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
Example #20
Source File: BukkitBridge.java From BungeeTabListPlus with GNU General Public License v3.0 | 5 votes |
private void removeObsoleteConnections() { synchronized (this) { ObjectIterator<Server> iterator = connections.iterator(); while (iterator.hasNext()) { Server server = iterator.next(); if (!server.isConnected()) { iterator.remove(); } } } }
Example #21
Source File: Anvil.java From Nukkit with GNU General Public License v3.0 | 5 votes |
@Override public void doGarbageCollection(long time) { long start = System.currentTimeMillis(); int maxIterations = size(); if (lastPosition > maxIterations) lastPosition = 0; ObjectIterator<BaseFullChunk> iter = getChunks(); if (lastPosition != 0) iter.skip(lastPosition); int i; for (i = 0; i < maxIterations; i++) { if (!iter.hasNext()) { iter = getChunks(); } BaseFullChunk chunk = iter.next(); if (chunk == null) continue; if (chunk.isGenerated() && chunk.isPopulated() && chunk instanceof Chunk) { Chunk anvilChunk = (Chunk) chunk; for (cn.nukkit.level.format.ChunkSection section : anvilChunk.getSections()) { if (section instanceof ChunkSection) { ChunkSection anvilSection = (ChunkSection) section; if (!anvilSection.isEmpty()) { anvilSection.compress(); } } } if (System.currentTimeMillis() - start >= time) break; } } lastPosition += i; }
Example #22
Source File: BlockVectorSet.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public Iterator<Vector> iterator() { final ObjectIterator<Int2ObjectMap.Entry<LocalBlockVectorSet>> entries = localSets.int2ObjectEntrySet().iterator(); if (!entries.hasNext()) { return new ArrayList<Vector>().iterator(); } return new Iterator<Vector>() { Int2ObjectMap.Entry<LocalBlockVectorSet> entry = entries.next(); Iterator<Vector> entryIter = entry.getValue().iterator(); MutableBlockVector mutable = new MutableBlockVector(); @Override public void remove() { entryIter.remove(); } @Override public boolean hasNext() { return entryIter.hasNext() || entries.hasNext(); } @Override public Vector next() { while (!entryIter.hasNext()) { if (!entries.hasNext()) { throw new NoSuchElementException("End of iterator"); } entry = entries.next(); entryIter = entry.getValue().iterator(); } Vector localPos = entryIter.next(); int pair = entry.getIntKey(); int cx = MathMan.unpairX(pair); int cz = MathMan.unpairY(pair); return mutable.setComponents((cx << 11) + localPos.getBlockX(), localPos.getBlockY(), (cz << 11) + localPos.getBlockZ()); } }; }
Example #23
Source File: WorldObjectContainer.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
public void moveItemsFrom(WorldObjectContainer otherInventory) { ObjectIterator<Entry<WorldObject>> iterator = otherInventory.worldObjects.int2ObjectEntrySet().fastIterator(); while(iterator.hasNext()) { Entry<WorldObject> otherEntry = iterator.next(); WorldObject otherWorldObject = otherEntry.getValue(); if (otherWorldObject.getProperty(Constants.QUANTITY) == null) { throw new IllegalStateException("otherWorldObject.getProperty(Constants.QUANTITY) is null: " + otherWorldObject); } addQuantity(otherWorldObject, otherWorldObject.getProperty(Constants.QUANTITY)); iterator.remove(); } }
Example #24
Source File: Fastutil.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Nonnull public static <K, V> ObjectIterable<Object2ObjectMap.Entry<K, V>> fastIterable( @Nonnull final Object2ObjectMap<K, V> map) { final ObjectSet<Object2ObjectMap.Entry<K, V>> entries = map.object2ObjectEntrySet(); return entries instanceof Object2ObjectMap.FastEntrySet ? new ObjectIterable<Object2ObjectMap.Entry<K, V>>() { @SuppressWarnings("unchecked") public ObjectIterator<Object2ObjectMap.Entry<K, V>> iterator() { return ((Object2ObjectMap.FastEntrySet<K, V>) entries).fastIterator(); } } : entries; }
Example #25
Source File: Fastutil.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Nonnull public static <V> ObjectIterable<Int2ObjectMap.Entry<V>> fastIterable( @Nonnull final Int2ObjectMap<V> map) { final ObjectSet<Int2ObjectMap.Entry<V>> entries = map.int2ObjectEntrySet(); return entries instanceof Int2ObjectMap.FastEntrySet ? new ObjectIterable<Int2ObjectMap.Entry<V>>() { public ObjectIterator<Int2ObjectMap.Entry<V>> iterator() { return ((Int2ObjectMap.FastEntrySet<V>) entries).fastIterator(); } } : entries; }
Example #26
Source File: Fastutil.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Nonnull public static ObjectIterable<Int2FloatMap.Entry> fastIterable(@Nonnull final Int2FloatMap map) { final ObjectSet<Int2FloatMap.Entry> entries = map.int2FloatEntrySet(); return entries instanceof Int2FloatMap.FastEntrySet ? new ObjectIterable<Int2FloatMap.Entry>() { public ObjectIterator<Int2FloatMap.Entry> iterator() { return ((Int2FloatMap.FastEntrySet) entries).fastIterator(); } } : entries; }
Example #27
Source File: Fastutil.java From incubator-hivemall with Apache License 2.0 | 5 votes |
@Nonnull public static ObjectIterable<Int2LongMap.Entry> fastIterable(@Nonnull final Int2LongMap map) { final ObjectSet<Int2LongMap.Entry> entries = map.int2LongEntrySet(); return entries instanceof Int2LongMap.FastEntrySet ? new ObjectIterable<Int2LongMap.Entry>() { public ObjectIterator<Int2LongMap.Entry> iterator() { return ((Int2LongMap.FastEntrySet) entries).fastIterator(); } } : entries; }
Example #28
Source File: VisitState.java From BUbiNG with Apache License 2.0 | 5 votes |
public void updateTermCount(final Short2ShortMap termCount) { termCountUpdates++; // In case we have an open hash map, we use the fast iterator to reduce object creation. if (termCount instanceof Short2ShortOpenHashMap) for(ObjectIterator<Short2ShortMap.Entry> fastIterator = ((Short2ShortOpenHashMap)termCount).short2ShortEntrySet().fastIterator(); fastIterator.hasNext();) updateTermCountEntry(fastIterator.next()); else for(Short2ShortMap.Entry e : termCount.short2ShortEntrySet()) updateTermCountEntry(e); }
Example #29
Source File: TmpPlistaTransaction.java From StreamingRec with Apache License 2.0 | 5 votes |
@Override public String toString() { String itemID; if (item == null) { itemID = "null"; } else { itemID = String.valueOf(item.id); } String keywords = ""; if(this.keywords!=null){ StringBuilder sb = new StringBuilder(); ObjectIterator<Entry<String>> fastIterator = this.keywords.object2IntEntrySet().fastIterator(); while(fastIterator.hasNext()){ Entry<String> next = fastIterator.next(); sb.append(next.getKey().replace("-","").replace("#", "")); sb.append("-"); sb.append(next.getIntValue()); if(fastIterator.hasNext()){ sb.append("#"); } } keywords = sb.toString(); } return publisher + Constants.CSV_SEPARATOR + category + Constants.CSV_SEPARATOR + itemID + Constants.CSV_SEPARATOR + cookie + Constants.CSV_SEPARATOR + timestamp.getTime() + Constants.CSV_SEPARATOR + keywords; }
Example #30
Source File: Level.java From Nukkit with GNU General Public License v3.0 | 5 votes |
public void doChunkGarbageCollection() { this.timings.doChunkGC.startTiming(); // remove all invaild block entities. if (!blockEntities.isEmpty()) { ObjectIterator<BlockEntity> iter = blockEntities.values().iterator(); while (iter.hasNext()) { BlockEntity blockEntity = iter.next(); if (blockEntity != null) { if (!blockEntity.isValid()) { iter.remove(); blockEntity.close(); } } else { iter.remove(); } } } for (Map.Entry<Long, ? extends FullChunk> entry : provider.getLoadedChunks().entrySet()) { long index = entry.getKey(); if (!this.unloadQueue.containsKey(index)) { FullChunk chunk = entry.getValue(); int X = chunk.getX(); int Z = chunk.getZ(); if (!this.isSpawnChunk(X, Z)) { this.unloadChunkRequest(X, Z, true); } } } this.provider.doGarbageCollection(); this.timings.doChunkGC.stopTiming(); }