Search in sources :

Example 1 with FloatIterable

use of org.eclipse.collections.api.FloatIterable 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 2 with FloatIterable

use of org.eclipse.collections.api.FloatIterable in project eclipse-collections by eclipse.

the class MapIterableTestCase method collectFloat.

@Test
public void collectFloat() {
    MapIterable<String, String> map = this.newMapWithKeysValues("One", "1", "Two", "2", "Three", "3");
    FloatIterable actual = map.collectFloat(Float::parseFloat);
    Assert.assertEquals(FloatHashBag.newBagWith(1.0f, 2.0f, 3.0f), actual.toBag());
}
Also used : FloatIterable(org.eclipse.collections.api.FloatIterable) Test(org.junit.Test)

Example 3 with FloatIterable

use of org.eclipse.collections.api.FloatIterable in project eclipse-collections by eclipse.

the class AbstractRichIterableTestCase method collectFloat.

@Test
public void collectFloat() {
    FloatIterable result = this.newWith(1, 2, 3, 4).collectFloat(PrimitiveFunctions.unboxIntegerToFloat());
    Assert.assertEquals(FloatBags.mutable.of(1.0f, 2.0f, 3.0f, 4.0f), result.toBag());
    Assert.assertEquals(FloatBags.mutable.of(1.0f, 2.0f, 3.0f, 4.0f), FloatBags.mutable.ofAll(result));
}
Also used : FloatIterable(org.eclipse.collections.api.FloatIterable) Test(org.junit.Test)

Aggregations

FloatIterable (org.eclipse.collections.api.FloatIterable)3 Test (org.junit.Test)3 MutableFloatCollection (org.eclipse.collections.api.collection.primitive.MutableFloatCollection)1 FloatArrayList (org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList)1