Search in sources :

Example 16 with ShortArrayList

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

the class AbstractLazyIterableTestCase method collectShortWithTarget.

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

Example 17 with ShortArrayList

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

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

the class IterateTest method collectShortWithTarget.

@Test
public void collectShortWithTarget() {
    this.iterables.each(each -> {
        MutableShortCollection expected = new ShortArrayList();
        MutableShortCollection actual = Iterate.collectShort(each, PrimitiveFunctions.unboxIntegerToShort(), expected);
        Assert.assertTrue(actual.containsAll((short) 1, (short) 2, (short) 3, (short) 4, (short) 5));
        Assert.assertSame("Target list sent as parameter not returned", expected, actual);
    });
    Verify.assertThrows(IllegalArgumentException.class, () -> Iterate.collectShort(null, PrimitiveFunctions.unboxIntegerToShort(), new ShortArrayList()));
}
Also used : MutableShortCollection(org.eclipse.collections.api.collection.primitive.MutableShortCollection) ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) Test(org.junit.Test)

Example 19 with ShortArrayList

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

the class SortedSetAdapter method collectShort.

@Override
public MutableShortList collectShort(ShortFunction<? super T> shortFunction) {
    ShortArrayList result = new ShortArrayList(this.size());
    this.forEach(new CollectShortProcedure<>(shortFunction, result));
    return result;
}
Also used : ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)

Example 20 with ShortArrayList

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

the class ImmutableEmptySortedBagTest method collectShort_target.

@Override
@Test
public void collectShort_target() {
    ImmutableSortedBag<Integer> bag = this.classUnderTest();
    Assert.assertEquals(new ShortArrayList(), bag.collectShort(PrimitiveFunctions.unboxIntegerToShort(), new ShortArrayList()));
    ImmutableSortedBag<Integer> bag2 = this.classUnderTest();
    Assert.assertEquals(new ShortHashBag(), bag2.collectShort(PrimitiveFunctions.unboxIntegerToShort(), new ShortHashBag()));
}
Also used : ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) ShortHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag) Test(org.junit.Test)

Aggregations

ShortArrayList (org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)20 Test (org.junit.Test)9 MutableShortCollection (org.eclipse.collections.api.collection.primitive.MutableShortCollection)3 MutableShortList (org.eclipse.collections.api.list.primitive.MutableShortList)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 BigInteger (java.math.BigInteger)1 ShortIterable (org.eclipse.collections.api.ShortIterable)1 ShortHashBag (org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag)1 AbstractSentinelValues (org.eclipse.collections.impl.map.mutable.primitive.AbstractSentinelValues)1