use of org.eclipse.collections.impl.block.function.NegativeIntervalFunction in project eclipse-collections by eclipse.
the class AbstractImmutableSortedSetTestCase method groupByEach.
@Test
public void groupByEach() {
ImmutableSortedSet<Integer> undertest = this.classUnderTest(Collections.reverseOrder());
NegativeIntervalFunction function = new NegativeIntervalFunction();
ImmutableSortedSetMultimap<Integer, Integer> actual = undertest.groupByEach(function);
ImmutableSortedSetMultimap<Integer, Integer> expected = TreeSortedSet.newSet(undertest).groupByEach(function).toImmutable();
Assert.assertEquals(expected, actual);
}
use of org.eclipse.collections.impl.block.function.NegativeIntervalFunction in project eclipse-collections by eclipse.
the class AbstractSortedSetTestCase method groupByEach.
@Override
@Test
public void groupByEach() {
super.groupByEach();
MutableSortedSet<Integer> set = this.newWith(Collections.reverseOrder(), 1, 2, 3, 4, 5, 6, 7);
NegativeIntervalFunction function = new NegativeIntervalFunction();
MutableSortedSetMultimap<Integer, Integer> expected = this.newWith(Collections.<Integer>reverseOrder()).groupByEach(function);
for (int i = 1; i < 8; i++) {
expected.putAll(-i, Interval.fromTo(i, 7));
}
MutableSortedSetMultimap<Integer, Integer> actual = set.groupByEach(function);
Assert.assertEquals(expected, actual);
MutableSortedSetMultimap<Integer, Integer> actualWithTarget = set.groupByEach(function, this.<Integer>newWith().groupByEach(function));
Assert.assertEquals(expected, actualWithTarget);
for (int i = 1; i < 8; ++i) {
Verify.assertSortedSetsEqual(expected.get(-i), actual.get(-i));
Verify.assertSortedSetsEqual(expected.get(-i), actualWithTarget.get(-i).toSortedSet(Collections.reverseOrder()));
}
Verify.assertSize(7, actual.keysView().toList());
Verify.assertSize(7, actualWithTarget.keysView().toList());
}
use of org.eclipse.collections.impl.block.function.NegativeIntervalFunction in project eclipse-collections by eclipse.
the class AbstractImmutableSetTestCase method groupByEachWithTarget.
@Test
public void groupByEachWithTarget() {
ImmutableSet<Integer> undertest = this.classUnderTest();
NegativeIntervalFunction function = new NegativeIntervalFunction();
UnifiedSetMultimap<Integer, Integer> actual = undertest.groupByEach(function, UnifiedSetMultimap.newMultimap());
UnifiedSetMultimap<Integer, Integer> expected = UnifiedSet.newSet(undertest).groupByEach(function);
Assert.assertEquals(expected, actual);
}
use of org.eclipse.collections.impl.block.function.NegativeIntervalFunction in project eclipse-collections by eclipse.
the class AbstractLazyIterableTestCase method groupByEach.
@Test
public void groupByEach() {
MutableMultimap<Integer, Integer> expected = FastListMultimap.newMultimap();
for (int i = 1; i < 8; i++) {
expected.putAll(-i, Interval.fromTo(i, 7));
}
Multimap<Integer, Integer> actual = this.lazyIterable.groupByEach(new NegativeIntervalFunction());
Assert.assertEquals(expected, actual);
Multimap<Integer, Integer> actualWithTarget = this.lazyIterable.groupByEach(new NegativeIntervalFunction(), FastListMultimap.newMultimap());
Assert.assertEquals(expected, actualWithTarget);
}
use of org.eclipse.collections.impl.block.function.NegativeIntervalFunction in project eclipse-collections by eclipse.
the class AbstractImmutableListTestCase method groupByEach.
@Test
public void groupByEach() {
ImmutableList<Integer> list = this.classUnderTest();
MutableMultimap<Integer, Integer> expected = FastListMultimap.newMultimap();
list.forEach(Procedures.cast(value -> expected.putAll(-value, Interval.fromTo(value, list.size()))));
Multimap<Integer, Integer> actual = list.groupByEach(new NegativeIntervalFunction());
Assert.assertEquals(expected, actual);
Multimap<Integer, Integer> actualWithTarget = list.groupByEach(new NegativeIntervalFunction(), FastListMultimap.newMultimap());
Assert.assertEquals(expected, actualWithTarget);
}
Aggregations