Search in sources :

Example 1 with ImmutableDoubleBag

use of org.eclipse.collections.api.bag.primitive.ImmutableDoubleBag in project eclipse-collections by eclipse.

the class ImmutableBagTestCase method collectDouble.

@Override
@Test
public void collectDouble() {
    super.collectDouble();
    ImmutableDoubleBag result = this.newBag().collectDouble(Double::parseDouble);
    Assert.assertEquals(this.numKeys(), result.sizeDistinct());
    for (int i = 1; i <= this.numKeys(); i++) {
        Assert.assertEquals(i, result.occurrencesOf(i));
    }
}
Also used : ImmutableDoubleBag(org.eclipse.collections.api.bag.primitive.ImmutableDoubleBag) Test(org.junit.Test)

Example 2 with ImmutableDoubleBag

use of org.eclipse.collections.api.bag.primitive.ImmutableDoubleBag in project eclipse-collections by eclipse.

the class PrimitiveStreamsTest method toImmutableDoubleBag.

@Test
public void toImmutableDoubleBag() {
    ImmutableDoubleBag bag = PrimitiveStreams.iDoubleBag(DoubleStream.of(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0));
    Assert.assertEquals(DoubleBags.mutable.ofAll(IntInterval.oneTo(10).asLazy().collectDouble(i -> (double) i)), bag);
    Assert.assertEquals(DoubleBags.mutable.ofAll(DoubleStream.of(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0)), bag);
}
Also used : ImmutableDoubleBag(org.eclipse.collections.api.bag.primitive.ImmutableDoubleBag) Test(org.junit.Test)

Aggregations

ImmutableDoubleBag (org.eclipse.collections.api.bag.primitive.ImmutableDoubleBag)2 Test (org.junit.Test)2