use of org.eclipse.collections.api.multimap.MutableMultimap in project eclipse-collections by eclipse.
the class StackIterableTestCase method groupByEach.
@Override
@Test
public void groupByEach() {
StackIterable<Integer> stack = this.newStackFromTopToBottom(1, 2, 3);
MutableMultimap<Integer, Integer> expected = FastListMultimap.newMultimap();
stack.forEach(Procedures.cast(value -> expected.putAll(-value, Interval.fromTo(value, stack.size()))));
Multimap<Integer, Integer> actual = stack.groupByEach(new NegativeIntervalFunction());
Assert.assertEquals(expected, actual);
Multimap<Integer, Integer> actualWithTarget = stack.groupByEach(new NegativeIntervalFunction(), FastListMultimap.newMultimap());
Assert.assertEquals(expected, actualWithTarget);
}
use of org.eclipse.collections.api.multimap.MutableMultimap in project eclipse-collections by eclipse.
the class AbstractMemoryEfficientMutableSetTestCase method groupByEach.
@Test
public void groupByEach() {
MutableSet<Integer> set = this.classUnderTest().collect(Integer::valueOf);
MutableMultimap<Integer, Integer> expected = UnifiedSetMultimap.newMultimap();
set.forEach(Procedures.cast(value -> expected.putAll(-value, Interval.fromTo(value, set.size()))));
Multimap<Integer, Integer> actual = set.groupByEach(new NegativeIntervalFunction());
Assert.assertEquals(expected, actual);
Multimap<Integer, Integer> actualWithTarget = set.groupByEach(new NegativeIntervalFunction(), UnifiedSetMultimap.newMultimap());
Assert.assertEquals(expected, actualWithTarget);
}
use of org.eclipse.collections.api.multimap.MutableMultimap in project eclipse-collections by eclipse.
the class DoubletonSetTest method groupByEach.
@Override
@Test
public void groupByEach() {
super.groupByEach();
MutableSet<Integer> set = Sets.fixedSize.of(1, 2);
MutableMultimap<Integer, Integer> expected = UnifiedSetMultimap.newMultimap();
set.forEach(Procedures.cast(value -> expected.putAll(-value, Interval.fromTo(value, set.size()))));
Multimap<Integer, Integer> actual = set.groupByEach(new NegativeIntervalFunction());
Assert.assertEquals(expected, actual);
Multimap<Integer, Integer> actualWithTarget = set.groupByEach(new NegativeIntervalFunction(), UnifiedSetMultimap.newMultimap());
Assert.assertEquals(expected, actualWithTarget);
}
use of org.eclipse.collections.api.multimap.MutableMultimap 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