Search in sources :

Example 1 with DoubleIterable

use of org.eclipse.collections.api.DoubleIterable in project eclipse-collections by eclipse.

the class AbstractRichIterableTestCase method collectDoubleWithTarget.

@Test
public void collectDoubleWithTarget() {
    MutableDoubleCollection target = new DoubleArrayList();
    DoubleIterable 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.toBag());
}
Also used : MutableDoubleCollection(org.eclipse.collections.api.collection.primitive.MutableDoubleCollection) DoubleIterable(org.eclipse.collections.api.DoubleIterable) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) Test(org.junit.Test)

Example 2 with DoubleIterable

use of org.eclipse.collections.api.DoubleIterable in project eclipse-collections by eclipse.

the class MapIterableTestCase method collectDouble.

@Test
public void collectDouble() {
    MapIterable<String, String> map = this.newMapWithKeysValues("One", "1", "Two", "2", "Three", "3");
    DoubleIterable actual = map.collectDouble(Double::parseDouble);
    Assert.assertEquals(DoubleHashBag.newBagWith(1.0d, 2.0d, 3.0d), actual.toBag());
}
Also used : DoubleIterable(org.eclipse.collections.api.DoubleIterable) Test(org.junit.Test)

Example 3 with DoubleIterable

use of org.eclipse.collections.api.DoubleIterable in project eclipse-collections by eclipse.

the class AbstractRichIterableTestCase method collectDouble.

@Test
public void collectDouble() {
    DoubleIterable result = this.newWith(1, 2, 3, 4).collectDouble(PrimitiveFunctions.unboxIntegerToDouble());
    Assert.assertEquals(DoubleBags.mutable.of(1.0d, 2.0d, 3.0d, 4.0d), result.toBag());
    Assert.assertEquals(DoubleBags.mutable.of(1.0d, 2.0d, 3.0d, 4.0d), DoubleBags.mutable.ofAll(result));
}
Also used : DoubleIterable(org.eclipse.collections.api.DoubleIterable) Test(org.junit.Test)

Aggregations

DoubleIterable (org.eclipse.collections.api.DoubleIterable)3 Test (org.junit.Test)3 MutableDoubleCollection (org.eclipse.collections.api.collection.primitive.MutableDoubleCollection)1 DoubleArrayList (org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList)1