use of org.eclipse.collections.impl.list.Interval in project eclipse-collections by eclipse.
the class MutableListTestCase method MutableList_shuffleThis.
@Test
default void MutableList_shuffleThis() {
Integer[] integers = Interval.oneTo(50).toArray();
MutableList<Integer> mutableList1 = this.newWith(integers);
MutableList<Integer> mutableList2 = this.newWith(integers);
Collections.shuffle(mutableList1, new Random(10));
assertEquals(mutableList1, mutableList2.shuffleThis(new Random(10)));
MutableList<Integer> list = this.newWith(1, 2, 3);
UnifiedSet<ImmutableList<Integer>> objects = UnifiedSet.newSet();
while (objects.size() < 6) {
objects.add(list.shuffleThis().toImmutable());
}
Interval interval = Interval.oneTo(1000);
MutableList<Integer> bigList = this.newWith(interval.toArray());
MutableList<Integer> shuffledBigList = bigList.shuffleThis(new Random(8));
MutableList<Integer> integers1 = this.newWith(interval.toArray());
assertEquals(integers1.shuffleThis(new Random(8)), bigList);
assertSame(bigList, shuffledBigList);
assertSame(bigList, bigList.shuffleThis());
assertSame(bigList, bigList.shuffleThis(new Random(8)));
assertEquals(interval.toBag(), bigList.toBag());
}
use of org.eclipse.collections.impl.list.Interval in project eclipse-collections by eclipse.
the class Collectors2Test method countBy.
@Test
public void countBy() {
Interval integers = Interval.oneTo(100);
MutableBag<Integer> counts = integers.stream().collect(Collectors2.countBy(i -> i % 2));
Assert.assertEquals(integers.countBy(i -> i % 2), counts);
Assert.assertEquals(50, counts.occurrencesOf(0));
Assert.assertEquals(50, counts.occurrencesOf(1));
}
Aggregations