use of org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList in project eclipse-collections by eclipse.
the class ArrayIterateTest method collectShortWithTarget.
@Test
public void collectShortWithTarget() {
Integer[] objectArray = { -1, 0, 42 };
ShortArrayList target = new ShortArrayList();
ShortArrayList result = ArrayIterate.collectShort(objectArray, PrimitiveFunctions.unboxIntegerToShort(), target);
Assert.assertEquals(this.getExpectedShortResults(), result);
Assert.assertSame("Target List not returned as result", target, result);
}
use of org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList 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);
}
use of org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList 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);
}
use of org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList 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);
}
use of org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList in project eclipse-collections by eclipse.
the class AbstractImmutableList method collectShort.
@Override
public ImmutableShortList collectShort(ShortFunction<? super T> shortFunction) {
ShortArrayList result = new ShortArrayList(this.size());
this.forEach(new CollectShortProcedure<>(shortFunction, result));
return result.toImmutable();
}
Aggregations