@Benchmark public void serial_eager_ec() { MutableSetMultimap<Alphagram, String> groupBy = this.ecWords.groupBy(Alphagram::new); groupBy .multiValuesView() .select(iterable -> iterable.size() >= SIZE_THRESHOLD) .toSortedList(Comparators.<RichIterable<String>>byIntFunction(RichIterable::size)) .asReversed() .collect(iterable -> iterable.size() + ": " + iterable) .forEach(Procedures.cast(e -> Assert.assertFalse(e.isEmpty()))); }
@Benchmark public void parallel_eager_forkjoin_ec() { MutableMultimap<Alphagram, String> groupBy = FJIterate.groupBy(this.ecWords, Alphagram::new); CompositeFastList<RichIterable<String>> select = FJIterate.select( groupBy.multiValuesView(), iterable -> iterable.size() >= SIZE_THRESHOLD, new CompositeFastList<>(), false); Collection<String> collect = FJIterate.collect( select .toSortedList(Comparators.<RichIterable<String>>byIntFunction(RichIterable::size)) .asReversed(), iterable -> iterable.size() + ": " + iterable); FJIterate.forEach(collect, Procedures.cast(e -> Assert.assertFalse(e.isEmpty()))); }
@Benchmark public void parallel_lazy_ec() { UnsortedSetMultimap<Alphagram, String> multimap = this.ecWords.asParallel(this.executorService, BATCH_SIZE).groupBy(Alphagram::new); FastList<Pair<Integer, String>> pairs = (FastList<Pair<Integer, String>>) FastList.newList(multimap.multiValuesView()) .asParallel(this.executorService, BATCH_SIZE) .select(iterable -> iterable.size() >= SIZE_THRESHOLD) .collect( iterable -> Tuples.pair(iterable.size(), iterable.size() + ": " + iterable)) .toSortedList((pair1, pair2) -> Integer.compare(pair2.getOne(), pair1.getOne())); pairs .asParallel(this.executorService, BATCH_SIZE) .collect(Pair::getTwo) .forEach(Procedures.cast(e -> Assert.assertFalse(e.isEmpty()))); }
@Override public <P> void forEachWith(Procedure2<? super T, ? super P> procedure, P parameter) { this.adapted.reverseForEach(Procedures.bind(procedure, parameter)); }
@Override public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure) { this.adapted.reverseForEach(Procedures.fromObjectIntProcedure(objectIntProcedure)); }