Search in sources :

Example 1 with MutableByteList

use of org.eclipse.collections.api.list.primitive.MutableByteList 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 2 with MutableByteList

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

the class ArrayListIterateTest method collectByte.

@Test
public void collectByte() {
    ArrayList<Integer> list = this.createIntegerList();
    MutableByteList actual = ArrayListIterate.collectByte(list, PrimitiveFunctions.unboxIntegerToByte());
    Assert.assertEquals(ByteArrayList.newListWith((byte) -1, (byte) 0, (byte) 4), actual);
}
Also used : MutableByteList(org.eclipse.collections.api.list.primitive.MutableByteList) Test(org.junit.Test)

Example 3 with MutableByteList

use of org.eclipse.collections.api.list.primitive.MutableByteList 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 4 with MutableByteList

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

the class ArrayListIterateTest method collectByteWithTarget.

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

Example 5 with MutableByteList

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

the class AbstractListTestCase method collectByte.

@Override
public void collectByte() {
    super.collectByte();
    MutableByteList result = this.newWith(1, 2, 3, 4).collectByte(PrimitiveFunctions.unboxIntegerToByte());
    Assert.assertEquals(ByteLists.mutable.of((byte) 1, (byte) 2, (byte) 3, (byte) 4), result);
}
Also used : MutableByteList(org.eclipse.collections.api.list.primitive.MutableByteList)

Aggregations

MutableByteList (org.eclipse.collections.api.list.primitive.MutableByteList)5 Test (org.junit.Test)4 ByteArrayList (org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)3 ArrayList (java.util.ArrayList)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