Search in sources :

Example 1 with MutableDoubleCollection

use of org.eclipse.collections.api.collection.primitive.MutableDoubleCollection in project eclipse-collections by eclipse.

the class AbstractLazyIterableTestCase method collectDoubleWithTarget.

@Test
public void collectDoubleWithTarget() {
    MutableDoubleCollection target = new DoubleArrayList();
    MutableDoubleCollection result = this.lazyIterable.collectDouble(PrimitiveFunctions.unboxIntegerToDouble(), target);
    Assert.assertEquals(DoubleArrayList.newListWith(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d), result.toList());
    Assert.assertSame("Target list sent as parameter not returned", target, result);
}
Also used : MutableDoubleCollection(org.eclipse.collections.api.collection.primitive.MutableDoubleCollection) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) Test(org.junit.Test)

Example 2 with MutableDoubleCollection

use of org.eclipse.collections.api.collection.primitive.MutableDoubleCollection 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 3 with MutableDoubleCollection

use of org.eclipse.collections.api.collection.primitive.MutableDoubleCollection in project eclipse-collections by eclipse.

the class IterateTest method collectDouble.

@Test
public void collectDouble() {
    this.iterables.each(each -> {
        MutableDoubleCollection result = Iterate.collectDouble(each, PrimitiveFunctions.unboxIntegerToDouble());
        Assert.assertTrue(result.containsAll(1.0d, 2.0d, 3.0d, 4.0d, 5.0d));
    });
    Verify.assertThrows(IllegalArgumentException.class, () -> Iterate.collectDouble(null, PrimitiveFunctions.unboxIntegerToDouble()));
}
Also used : MutableDoubleCollection(org.eclipse.collections.api.collection.primitive.MutableDoubleCollection) Test(org.junit.Test)

Example 4 with MutableDoubleCollection

use of org.eclipse.collections.api.collection.primitive.MutableDoubleCollection in project eclipse-collections by eclipse.

the class IterateTest method collectDoubleWithTarget.

@Test
public void collectDoubleWithTarget() {
    this.iterables.each(each -> {
        MutableDoubleCollection expected = new DoubleArrayList();
        MutableDoubleCollection actual = Iterate.collectDouble(each, PrimitiveFunctions.unboxIntegerToDouble(), expected);
        Assert.assertTrue(actual.containsAll(1.0d, 2.0d, 3.0d, 4.0d, 5.0d));
        Assert.assertSame("Target list sent as parameter not returned", expected, actual);
    });
    Verify.assertThrows(IllegalArgumentException.class, () -> Iterate.collectDouble(null, PrimitiveFunctions.unboxIntegerToDouble(), new DoubleArrayList()));
}
Also used : MutableDoubleCollection(org.eclipse.collections.api.collection.primitive.MutableDoubleCollection) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) Test(org.junit.Test)

Example 5 with MutableDoubleCollection

use of org.eclipse.collections.api.collection.primitive.MutableDoubleCollection in project eclipse-collections by eclipse.

the class MapIterateTest method collectDouble.

@Test
public void collectDouble() {
    MutableDoubleCollection result = MapIterate.collectDouble(MapIterateTest.newLittleMap(), PrimitiveFunctions.unboxIntegerToDouble());
    Assert.assertEquals(DoubleHashBag.newBagWith(1, 2), result.toBag());
}
Also used : MutableDoubleCollection(org.eclipse.collections.api.collection.primitive.MutableDoubleCollection) Test(org.junit.Test)

Aggregations

MutableDoubleCollection (org.eclipse.collections.api.collection.primitive.MutableDoubleCollection)9 Test (org.junit.Test)7 MutableBooleanCollection (org.eclipse.collections.api.collection.primitive.MutableBooleanCollection)4 MutableByteCollection (org.eclipse.collections.api.collection.primitive.MutableByteCollection)4 MutableCharCollection (org.eclipse.collections.api.collection.primitive.MutableCharCollection)4 MutableFloatCollection (org.eclipse.collections.api.collection.primitive.MutableFloatCollection)4 MutableIntCollection (org.eclipse.collections.api.collection.primitive.MutableIntCollection)4 MutableLongCollection (org.eclipse.collections.api.collection.primitive.MutableLongCollection)4 MutableShortCollection (org.eclipse.collections.api.collection.primitive.MutableShortCollection)4 Optional (java.util.Optional)3 RichIterable (org.eclipse.collections.api.RichIterable)3 MutableCollection (org.eclipse.collections.api.collection.MutableCollection)3 MutableList (org.eclipse.collections.api.list.MutableList)3 Pair (org.eclipse.collections.api.tuple.Pair)3 Predicates2 (org.eclipse.collections.impl.block.factory.Predicates2)3 Lists (org.eclipse.collections.impl.factory.Lists)3 DoubleArrayList (org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList)3 List (java.util.List)2 Map (java.util.Map)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2