Search in sources :

Example 1 with MutableDoubleList

use of org.eclipse.collections.api.list.primitive.MutableDoubleList in project eclipse-collections by eclipse.

the class ArrayListIterateTest method collectDoubleOverOptimizeLimit.

@Test
public void collectDoubleOverOptimizeLimit() {
    ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
    MutableDoubleList actual = ArrayListIterate.collectDouble(list, PrimitiveFunctions.unboxIntegerToDouble());
    DoubleArrayList expected = new DoubleArrayList(list.size());
    for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
        expected.add((double) i);
    }
    Assert.assertEquals(expected, actual);
}
Also used : MutableDoubleList(org.eclipse.collections.api.list.primitive.MutableDoubleList) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) CharArrayList(org.eclipse.collections.impl.list.mutable.primitive.CharArrayList) FloatArrayList(org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList) LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) ArrayList(java.util.ArrayList) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) Test(org.junit.Test)

Example 2 with MutableDoubleList

use of org.eclipse.collections.api.list.primitive.MutableDoubleList in project eclipse-collections by eclipse.

the class ArrayListIterateTest method collectDoubleWithTargetOverOptimizeLimit.

@Test
public void collectDoubleWithTargetOverOptimizeLimit() {
    ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
    MutableDoubleList target = new DoubleArrayList();
    MutableDoubleList actual = ArrayListIterate.collectDouble(list, PrimitiveFunctions.unboxIntegerToDouble(), target);
    DoubleArrayList expected = new DoubleArrayList(list.size());
    for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
        expected.add((double) i);
    }
    Assert.assertEquals(expected, actual);
    Assert.assertSame("Target sent as parameter was not returned as result", target, actual);
}
Also used : MutableDoubleList(org.eclipse.collections.api.list.primitive.MutableDoubleList) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) CharArrayList(org.eclipse.collections.impl.list.mutable.primitive.CharArrayList) FloatArrayList(org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList) LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) ArrayList(java.util.ArrayList) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) Test(org.junit.Test)

Example 3 with MutableDoubleList

use of org.eclipse.collections.api.list.primitive.MutableDoubleList in project eclipse-collections by eclipse.

the class ArrayListIterateTest method collectDoubleWithTarget.

@Test
public void collectDoubleWithTarget() {
    ArrayList<Integer> list = this.createIntegerList();
    MutableDoubleList target = new DoubleArrayList();
    MutableDoubleList actual = ArrayListIterate.collectDouble(list, PrimitiveFunctions.unboxIntegerToDouble(), target);
    Assert.assertSame("Target list sent as parameter not returned", target, actual);
    Assert.assertEquals(DoubleArrayList.newListWith(-1.0d, 0.0d, 4.0d), actual);
}
Also used : MutableDoubleList(org.eclipse.collections.api.list.primitive.MutableDoubleList) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) Test(org.junit.Test)

Example 4 with MutableDoubleList

use of org.eclipse.collections.api.list.primitive.MutableDoubleList in project eclipse-collections by eclipse.

the class PrimitiveStreamsTest method toDoubleList.

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

Example 5 with MutableDoubleList

use of org.eclipse.collections.api.list.primitive.MutableDoubleList in project eclipse-collections by eclipse.

the class ArrayListIterateTest method collectDouble.

@Test
public void collectDouble() {
    ArrayList<Integer> list = this.createIntegerList();
    MutableDoubleList actual = ArrayListIterate.collectDouble(list, PrimitiveFunctions.unboxIntegerToDouble());
    Assert.assertEquals(DoubleArrayList.newListWith(-1.0d, 0.0d, 4.0d), actual);
}
Also used : MutableDoubleList(org.eclipse.collections.api.list.primitive.MutableDoubleList) Test(org.junit.Test)

Aggregations

MutableDoubleList (org.eclipse.collections.api.list.primitive.MutableDoubleList)6 Test (org.junit.Test)5 DoubleArrayList (org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList)3 ArrayList (java.util.ArrayList)2 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)2 ByteArrayList (org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)2 CharArrayList (org.eclipse.collections.impl.list.mutable.primitive.CharArrayList)2 FloatArrayList (org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList)2 IntArrayList (org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)2 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)2 ShortArrayList (org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)2