use of org.eclipse.collections.api.bag.primitive.ImmutableIntBag in project eclipse-collections by eclipse.
the class ImmutableBagTestCase method collectInt.
@Override
@Test
public void collectInt() {
super.collectInt();
ImmutableIntBag result = this.newBag().collectInt(Integer::parseInt);
Assert.assertEquals(this.numKeys(), result.sizeDistinct());
for (int i = 1; i <= this.numKeys(); i++) {
Assert.assertEquals(i, result.occurrencesOf(i));
}
}
use of org.eclipse.collections.api.bag.primitive.ImmutableIntBag in project eclipse-collections by eclipse.
the class PersonAndPetKataTest method getCountsByPetAge.
@Test
public void getCountsByPetAge() {
ImmutableIntBag countsLazy = this.people.asLazy().flatCollect(Person::getPets).collectInt(Pet::getAge).toBag().toImmutable();
Assert.assertEquals(4, countsLazy.occurrencesOf(1));
Assert.assertEquals(3, countsLazy.occurrencesOf(2));
Assert.assertEquals(1, countsLazy.occurrencesOf(3));
Assert.assertEquals(1, countsLazy.occurrencesOf(4));
Assert.assertEquals(0, countsLazy.occurrencesOf(5));
}
use of org.eclipse.collections.api.bag.primitive.ImmutableIntBag in project eclipse-collections by eclipse.
the class PrimitiveStreamsTest method toImmutableIntBag.
@Test
public void toImmutableIntBag() {
ImmutableIntBag bag = PrimitiveStreams.iIntBag(IntStream.rangeClosed(1, 10));
Assert.assertEquals(IntInterval.oneTo(10).toBag(), bag);
Assert.assertEquals(IntBags.mutable.ofAll(IntStream.rangeClosed(1, 10)), bag);
}
Aggregations