/** * Returns a stream of the elements stored in the structure. * * @return a stream of the elements stored in the structure */ public Stream<T> getIds() { return t2imap.keySet().stream(); } }
@Override public double evaluate() { return itemCount.keySet().stream() .mapToDouble((i) -> itemWeight.getDouble(i) * nov(i)) .sum() / numUsers; }
protected Collection<ObjectFloatPair<String>> getBagOfLexicons(Object2FloatMap<String> map, Field type) { switch (type) { case bag_of_words: case bag_of_clusters: case bag_of_words_stopwords: case bag_of_clusters_stopwords: return map.entrySet().stream().map(e -> new ObjectFloatPair<>(e.getKey(), 1f)).collect(Collectors.toList()); case bag_of_words_count: case bag_of_clusters_count: case bag_of_words_stopwords_count: case bag_of_clusters_stopwords_count: return map.entrySet().stream().map(e -> new ObjectFloatPair<>(e.getKey(), e.getValue())).collect(Collectors.toList()); case bag_of_words_norm: case bag_of_clusters_norm: case bag_of_words_stopwords_norm: case bag_of_clusters_stopwords_norm: // float total = (float)map.entrySet().stream().mapToDouble(e -> e.getValue()).sum(); return map.entrySet().stream().map(e -> new ObjectFloatPair<>(e.getKey(), (float)MathUtils.sigmoid(e.getValue()))).collect(Collectors.toList()); default: return null; } }
protected Collection<ObjectFloatPair<String>> getBagOfLexicons(Object2FloatMap<String> map, Field type) { switch (type) { case bag_of_words: case bag_of_clusters: case bag_of_words_stopwords: case bag_of_clusters_stopwords: return map.entrySet().stream().map(e -> new ObjectFloatPair<>(e.getKey(), 1f)).collect(Collectors.toList()); case bag_of_words_count: case bag_of_clusters_count: case bag_of_words_stopwords_count: case bag_of_clusters_stopwords_count: return map.entrySet().stream().map(e -> new ObjectFloatPair<>(e.getKey(), e.getValue())).collect(Collectors.toList()); case bag_of_words_norm: case bag_of_clusters_norm: case bag_of_words_stopwords_norm: case bag_of_clusters_stopwords_norm: // float total = (float)map.entrySet().stream().mapToDouble(e -> e.getValue()).sum(); return map.entrySet().stream().map(e -> new ObjectFloatPair<>(e.getKey(), (float)MathUtils.sigmoid(e.getValue()))).collect(Collectors.toList()); default: return null; } }
public void trackRegions(WorldServer world, PlayerChunkMap chunkTracker) { List<PlayerChunkMapEntry> chunkEntries = PlayerChunkMapHooks.getSortedChunkEntries(chunkTracker); Set<ChunkPos> trackedChunks = chunkEntries.stream() .map(PlayerChunkMapEntry::getPos) .collect(Collectors.toSet()); Set<ChunkPos> untrackedChunks = this.chunkStateMap.keySet().stream() .filter(pos -> !trackedChunks.contains(pos)) .collect(Collectors.toSet()); untrackedChunks.forEach(this.chunkStateMap::remove); Collection<RegionTilePos> requiredRegions = this.collectRequiredRegions(world, chunkTracker, chunkEntries); if (chunkTracker instanceof PlayerChunkMapHooks.Wrapper) { PlayerChunkMapHooks.Wrapper hookedTracker = (PlayerChunkMapHooks.Wrapper) chunkTracker; Set<ChunkPos> hookedChunks = hookedTracker.getHookedChunks(); if (!hookedChunks.isEmpty()) { Set<ChunkPos> unhooked = hookedChunks.stream() .filter(chunkPos -> { RegionTilePos regionPos = this.getRegionPos(chunkPos.getXStart(), chunkPos.getZStart()); return this.regionCache.containsKey(regionPos); }) .collect(Collectors.toSet()); unhooked.forEach(hookedTracker::unhookChunk); } } this.trackRegions(requiredRegions); }
public boolean sanityCheck() { graphByKmerNode.long2ObjectEntrySet().stream().flatMap(e -> e.getValue().stream()).forEach(kn -> { assert(kn.node().isValid()); assert(graphByPosition.contains(kn.node())); }); for (KmerPathNode n : graphByPosition) { assert(n.isValid()); assert(evidenceTracker.matchesExpected(new KmerPathSubnode(n))); } if (Defaults.SANITY_CHECK_MEMOIZATION && Defaults.SANITY_CHECK_MEMOIZATION_ALL_OPERATIONS) { if (bestContigCaller != null) assert(bestContigCaller.sanityCheck()); } return true; } public boolean sanityCheckDisjointNodeIntervals() {
/** * Performs an operation on index-value pairs of the non-zero instance * features. * * @param function int-double function * @param reducer aggregating operator of the results of the function * @return stream of double values resulting from applying the function */ public double operate(FeatureDoubleFunction function, DoubleBinaryOperator reducer) { return features.int2DoubleEntrySet().stream() .mapToDouble(e -> function.apply(e.getIntKey(), e.getDoubleValue())) .reduce(reducer).orElse(NaN); }
@Override public Stream<Tuple2id> similarElems(int idx1) { if (dense) { double norm2A = norm2Array[idx1]; double[] productArray = getProductArray(idx1); return range(0, productArray.length) .filter(idx2 -> productArray[idx2] != 0.0) .mapToObj(idx2 -> tuple(idx2, sim(productArray[idx2], norm2A, norm2Array[idx2]))); } else { double norm2A = norm2Map.get(idx1); return getProductMap(idx1).int2DoubleEntrySet().stream() .map(e -> { int idx2 = e.getIntKey(); double product = e.getDoubleValue(); double norm2B = norm2Map.get(idx2); return tuple(idx2, sim(product, norm2A, norm2B)); }); } }
.mapToObj(i -> tuple(i, sim(intersectionMap[i], na, data.numItems(i)))); } else { return getFasterIntersectionMap(idx1).int2IntEntrySet().stream() .map(e -> { int idx2 = e.getIntKey(); .mapToObj(i -> tuple(i, sim(intersectionMap[i], na, data.numItems(i)))); } else { return getIntersectionMap(idx1).int2IntEntrySet().stream() .map(e -> { int idx2 = e.getIntKey();