Search in sources :

Example 1 with ShortIterable

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

the class AbstractRichIterableTestCase method collectShort.

@Test
public void collectShort() {
    ShortIterable result = this.newWith(1, 2, 3, 4).collectShort(PrimitiveFunctions.unboxIntegerToShort());
    Assert.assertEquals(ShortBags.mutable.of((short) 1, (short) 2, (short) 3, (short) 4), result.toBag());
    Assert.assertEquals(ShortBags.mutable.of((short) 1, (short) 2, (short) 3, (short) 4), ShortBags.mutable.ofAll(result));
}
Also used : ShortIterable(org.eclipse.collections.api.ShortIterable) Test(org.junit.Test)

Example 2 with ShortIterable

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

the class AbstractRichIterableTestCase method collectShortWithTarget.

@Test
public void collectShortWithTarget() {
    MutableShortCollection target = new ShortArrayList();
    ShortIterable result = this.newWith(1, 2, 3, 4).collectShort(PrimitiveFunctions.unboxIntegerToShort(), target);
    Assert.assertSame("Target list sent as parameter not returned", target, result);
    Assert.assertEquals(ShortHashBag.newBagWith((short) 1, (short) 2, (short) 3, (short) 4), result.toBag());
}
Also used : MutableShortCollection(org.eclipse.collections.api.collection.primitive.MutableShortCollection) ShortIterable(org.eclipse.collections.api.ShortIterable) ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) Test(org.junit.Test)

Example 3 with ShortIterable

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

the class MapIterableTestCase method collectShort.

@Test
public void collectShort() {
    MapIterable<String, String> map = this.newMapWithKeysValues("One", "1", "Two", "2", "Three", "3");
    ShortIterable actual = map.collectShort(Short::parseShort);
    Assert.assertEquals(ShortHashBag.newBagWith((short) 1, (short) 2, (short) 3), actual.toBag());
}
Also used : ShortIterable(org.eclipse.collections.api.ShortIterable) Test(org.junit.Test)

Aggregations

ShortIterable (org.eclipse.collections.api.ShortIterable)3 Test (org.junit.Test)3 MutableShortCollection (org.eclipse.collections.api.collection.primitive.MutableShortCollection)1 ShortArrayList (org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)1