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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations