Search in sources :

Example 1 with MutableShortList

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

the class ArrayListIterateTest method collectShortWithTarget.

@Test
public void collectShortWithTarget() {
    ArrayList<Integer> list = this.createIntegerList();
    MutableShortList target = new ShortArrayList();
    MutableShortList actual = ArrayListIterate.collectShort(list, PrimitiveFunctions.unboxIntegerToShort(), target);
    Assert.assertSame("Target list sent as parameter not returned", target, actual);
    Assert.assertEquals(ShortArrayList.newListWith((short) -1, (short) 0, (short) 4), actual);
}
Also used : ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) MutableShortList(org.eclipse.collections.api.list.primitive.MutableShortList) Test(org.junit.Test)

Example 2 with MutableShortList

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

the class ArrayListIterateTest method collectShortWithTargetOverOptimizeLimit.

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

Example 3 with MutableShortList

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

the class ArrayListIterateTest method collectShort.

@Test
public void collectShort() {
    ArrayList<Integer> list = this.createIntegerList();
    MutableShortList actual = ArrayListIterate.collectShort(list, PrimitiveFunctions.unboxIntegerToShort());
    Assert.assertEquals(ShortArrayList.newListWith((short) -1, (short) 0, (short) 4), actual);
}
Also used : MutableShortList(org.eclipse.collections.api.list.primitive.MutableShortList) Test(org.junit.Test)

Example 4 with MutableShortList

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

the class ArrayListIterateTest method collectShortOverOptimizeLimit.

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

Example 5 with MutableShortList

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

the class AbstractListTestCase method collectShort.

@Override
public void collectShort() {
    super.collectShort();
    MutableShortList result = this.newWith(1, 2, 3, 4).collectShort(PrimitiveFunctions.unboxIntegerToShort());
    Assert.assertEquals(ShortLists.mutable.of((short) 1, (short) 2, (short) 3, (short) 4), result);
}
Also used : MutableShortList(org.eclipse.collections.api.list.primitive.MutableShortList)

Aggregations

MutableShortList (org.eclipse.collections.api.list.primitive.MutableShortList)5 Test (org.junit.Test)4 ShortArrayList (org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)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 FloatArrayList (org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList)2 IntArrayList (org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)2 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)2