Search in sources :

Example 6 with ByteArrayList

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

the class AbstractRichIterableTestCase method collectByteWithTarget.

@Test
public void collectByteWithTarget() {
    MutableByteCollection target = new ByteArrayList();
    ByteIterable result = this.newWith(1, 2, 3, 4).collectByte(PrimitiveFunctions.unboxIntegerToByte(), target);
    Assert.assertSame("Target list sent as parameter not returned", target, result);
    Assert.assertEquals(ByteHashBag.newBagWith((byte) 1, (byte) 2, (byte) 3, (byte) 4), result.toBag());
}
Also used : ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) ByteIterable(org.eclipse.collections.api.ByteIterable) MutableByteCollection(org.eclipse.collections.api.collection.primitive.MutableByteCollection) Test(org.junit.Test)

Example 7 with ByteArrayList

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

the class ArrayListIterateTest method collectByteOverOptimizeLimit.

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

Example 8 with ByteArrayList

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

the class ArrayListIterateTest method collectByteWithTargetOverOptimizeLimit.

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

Example 9 with ByteArrayList

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

the class IterateTest method collectByteWithTarget.

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

Example 10 with ByteArrayList

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

the class ImmutableEmptySortedBagTest method collectByte.

@Override
@Test
public void collectByte() {
    ImmutableSortedBag<Integer> bag = this.classUnderTest();
    Assert.assertEquals(new ByteArrayList(), bag.collectByte(PrimitiveFunctions.unboxIntegerToByte()));
}
Also used : ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) Test(org.junit.Test)

Aggregations

ByteArrayList (org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)23 Test (org.junit.Test)11 MutableByteCollection (org.eclipse.collections.api.collection.primitive.MutableByteCollection)3 MutableByteList (org.eclipse.collections.api.list.primitive.MutableByteList)3 ArrayList (java.util.ArrayList)2 MutableByteSet (org.eclipse.collections.api.set.primitive.MutableByteSet)2 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)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 ShortArrayList (org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)2 BigInteger (java.math.BigInteger)1 ByteIterable (org.eclipse.collections.api.ByteIterable)1 ByteList (org.eclipse.collections.api.list.primitive.ByteList)1 ByteHashBag (org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag)1