Search in sources :

Example 6 with DoubleHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.DoubleHashBag in project eclipse-collections by eclipse.

the class ImmutableBagTestCase method collectDoubleWithTarget.

@Override
@Test
public void collectDoubleWithTarget() {
    super.collectDoubleWithTarget();
    DoubleHashBag target = new DoubleHashBag();
    DoubleHashBag result = this.newBag().collectDouble(Double::parseDouble, target);
    Assert.assertSame("Target sent as parameter not returned", target, result);
    Assert.assertEquals(this.numKeys(), result.sizeDistinct());
    for (int i = 1; i <= this.numKeys(); i++) {
        Assert.assertEquals(i, result.occurrencesOf(i));
    }
}
Also used : DoubleHashBag(org.eclipse.collections.impl.bag.mutable.primitive.DoubleHashBag) Test(org.junit.Test)

Example 7 with DoubleHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.DoubleHashBag in project eclipse-collections by eclipse.

the class AbstractRichIterableTestCase method collectDoubleWithBagTarget.

@Test
public void collectDoubleWithBagTarget() {
    DoubleHashBag target = new DoubleHashBag();
    DoubleHashBag result = this.newWith(1, 2, 3, 4).collectDouble(PrimitiveFunctions.unboxIntegerToDouble(), target);
    Assert.assertSame("Target list sent as parameter not returned", target, result);
    Assert.assertEquals(DoubleHashBag.newBagWith(1.0d, 2.0d, 3.0d, 4.0d), result);
}
Also used : DoubleHashBag(org.eclipse.collections.impl.bag.mutable.primitive.DoubleHashBag) Test(org.junit.Test)

Example 8 with DoubleHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.DoubleHashBag in project eclipse-collections by eclipse.

the class ImmutableEmptySortedBagTest method collectDouble_target.

@Override
@Test
public void collectDouble_target() {
    ImmutableSortedBag<Integer> bag = this.classUnderTest();
    Assert.assertEquals(new DoubleArrayList(), bag.collectDouble(PrimitiveFunctions.unboxIntegerToDouble(), new DoubleArrayList()));
    ImmutableSortedBag<Integer> bag2 = this.classUnderTest();
    Assert.assertEquals(new DoubleHashBag(), bag2.collectDouble(PrimitiveFunctions.unboxIntegerToDouble(), new DoubleHashBag()));
}
Also used : DoubleHashBag(org.eclipse.collections.impl.bag.mutable.primitive.DoubleHashBag) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) Test(org.junit.Test)

Aggregations

DoubleHashBag (org.eclipse.collections.impl.bag.mutable.primitive.DoubleHashBag)8 Test (org.junit.Test)6 MutableDoubleBag (org.eclipse.collections.api.bag.primitive.MutableDoubleBag)2 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Collectors (java.util.stream.Collectors)1 BooleanIterable (org.eclipse.collections.api.BooleanIterable)1 ByteIterable (org.eclipse.collections.api.ByteIterable)1 CharIterable (org.eclipse.collections.api.CharIterable)1 DoubleIterable (org.eclipse.collections.api.DoubleIterable)1 FloatIterable (org.eclipse.collections.api.FloatIterable)1 IntIterable (org.eclipse.collections.api.IntIterable)1 LongIterable (org.eclipse.collections.api.LongIterable)1 RichIterable (org.eclipse.collections.api.RichIterable)1 ShortIterable (org.eclipse.collections.api.ShortIterable)1