@Override public boolean contains(Object obj) { return Comparators.nullSafeEquals(obj, this.element1) || Comparators.nullSafeEquals(obj, this.element2) || Comparators.nullSafeEquals(obj, this.element3) || Comparators.nullSafeEquals(obj, this.element4) || Comparators.nullSafeEquals(obj, this.element5); }
@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()))); }
@Test(expected = NullPointerException.class) public void asParallel_null_executorService() { SortedSets.immutable.with(Comparators.reverseNaturalOrder()).asParallel(null, 2); }
@Test(expected = IllegalArgumentException.class) public void asParallel_small_batch() { SortedSets.immutable .with(Comparators.reverseNaturalOrder()) .asParallel(this.executorService, 0); }
@Override protected ParallelSortedSetIterable<Integer> newWith(Integer... littleElements) { return SortedSets.immutable .with(Comparators.<Integer>reverseNaturalOrder()) .asParallel(this.executorService, this.batchSize); }
@Override protected SortedSetIterable<Integer> getExpectedWith(Integer... littleElements) { return TreeSortedSet.newSetWith(Comparators.reverseNaturalOrder()); }
@Test public void max() { Assert.assertEquals( Integer.valueOf(1), this.newList().max(Comparators.reverse(Integer::compareTo))); }
@Override default <T> MutableSortedBag<T> newMutableForFilter(T... elements) { return new TreeBag<>(Comparators.reverseNaturalOrder(), Lists.immutable.with(elements)); }
@Override default <T> SortedBag<T> getExpectedFiltered(T... elements) { return new TreeBag<>(Comparators.reverseNaturalOrder(), Lists.immutable.with(elements)); }