Search in sources :

Example 1 with MutableFloatList

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

the class ArrayListIterateTest method collectFloatWithTargetOverOptimizeLimit.

@Test
public void collectFloatWithTargetOverOptimizeLimit() {
    ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
    MutableFloatList target = new FloatArrayList();
    MutableFloatList actual = ArrayListIterate.collectFloat(list, PrimitiveFunctions.unboxIntegerToFloat(), target);
    FloatArrayList expected = new FloatArrayList(list.size());
    for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
        expected.add((float) i);
    }
    Assert.assertEquals(expected, actual);
    Assert.assertSame("Target sent as parameter was not returned as result", target, actual);
}
Also used : 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) FloatArrayList(org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList) MutableFloatList(org.eclipse.collections.api.list.primitive.MutableFloatList) Test(org.junit.Test)

Example 2 with MutableFloatList

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

the class ArrayListIterateTest method collectFloat.

@Test
public void collectFloat() {
    ArrayList<Integer> list = this.createIntegerList();
    MutableFloatList actual = ArrayListIterate.collectFloat(list, PrimitiveFunctions.unboxIntegerToFloat());
    Assert.assertEquals(FloatArrayList.newListWith(-1.0f, 0.0f, 4.0f), actual);
}
Also used : MutableFloatList(org.eclipse.collections.api.list.primitive.MutableFloatList) Test(org.junit.Test)

Example 3 with MutableFloatList

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

the class ArrayListIterateTest method collectFloatOverOptimizeLimit.

@Test
public void collectFloatOverOptimizeLimit() {
    ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
    MutableFloatList actual = ArrayListIterate.collectFloat(list, PrimitiveFunctions.unboxIntegerToFloat());
    FloatArrayList expected = new FloatArrayList(list.size());
    for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
        expected.add((float) i);
    }
    Assert.assertEquals(expected, actual);
}
Also used : 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) FloatArrayList(org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList) MutableFloatList(org.eclipse.collections.api.list.primitive.MutableFloatList) Test(org.junit.Test)

Example 4 with MutableFloatList

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

the class ArrayListIterateTest method collectFloatWithTarget.

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

Example 5 with MutableFloatList

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

the class AbstractListTestCase method collectFloat.

@Override
public void collectFloat() {
    super.collectFloat();
    MutableFloatList result = this.newWith(1, 2, 3, 4).collectFloat(PrimitiveFunctions.unboxIntegerToFloat());
    Assert.assertEquals(FloatLists.mutable.of(1.0f, 2.0f, 3.0f, 4.0f), result);
}
Also used : MutableFloatList(org.eclipse.collections.api.list.primitive.MutableFloatList)

Aggregations

MutableFloatList (org.eclipse.collections.api.list.primitive.MutableFloatList)5 Test (org.junit.Test)4 FloatArrayList (org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList)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 DoubleArrayList (org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList)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