Search in sources :

Example 6 with FloatArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList in project eclipse-collections by eclipse.

the class AbstractRichIterableTestCase method collectFloatWithTarget.

@Test
public void collectFloatWithTarget() {
    MutableFloatCollection target = new FloatArrayList();
    FloatIterable result = this.newWith(1, 2, 3, 4).collectFloat(PrimitiveFunctions.unboxIntegerToFloat(), target);
    Assert.assertSame("Target list sent as parameter not returned", target, result);
    Assert.assertEquals(FloatHashBag.newBagWith(1.0f, 2.0f, 3.0f, 4.0f), result.toBag());
}
Also used : FloatIterable(org.eclipse.collections.api.FloatIterable) MutableFloatCollection(org.eclipse.collections.api.collection.primitive.MutableFloatCollection) FloatArrayList(org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList) Test(org.junit.Test)

Example 7 with FloatArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList in project eclipse-collections by eclipse.

the class ArrayIterateTest method collectFloatWithTarget.

@Test
public void collectFloatWithTarget() {
    Integer[] objectArray = { -1, 0, 42 };
    FloatArrayList target = new FloatArrayList();
    FloatArrayList result = ArrayIterate.collectFloat(objectArray, PrimitiveFunctions.unboxIntegerToFloat(), target);
    Assert.assertEquals(this.getExpectedFloatResults(), result);
    Assert.assertSame("Target List not returned as result", target, result);
}
Also used : BigInteger(java.math.BigInteger) FloatArrayList(org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList) Test(org.junit.Test)

Example 8 with FloatArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList 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 9 with FloatArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList 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 10 with FloatArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList in project eclipse-collections by eclipse.

the class IterateTest method collectFloatWithTarget.

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

Aggregations

FloatArrayList (org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList)19 Test (org.junit.Test)9 MutableFloatCollection (org.eclipse.collections.api.collection.primitive.MutableFloatCollection)3 MutableFloatList (org.eclipse.collections.api.list.primitive.MutableFloatList)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 BigInteger (java.math.BigInteger)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Util (jcog.Util)1 ListTopic (jcog.event.ListTopic)1 Topic (jcog.event.Topic)1 Loop (jcog.exe.Loop)1 OneDHaar (jcog.math.OneDHaar)1 FloatIterable (org.eclipse.collections.api.FloatIterable)1