Search in sources :

Example 16 with ByteArrayList

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

the class AbstractByteSetTestCase method addAllIterable.

@Override
@Test
public void addAllIterable() {
    super.addAllIterable();
    MutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) -1, (byte) -128);
    Assert.assertFalse(set.addAll(new ByteArrayList()));
    Assert.assertFalse(set.addAll(ByteArrayList.newListWith((byte) 31, (byte) -1, (byte) -128)));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 0, (byte) 1, (byte) 31, (byte) -1, (byte) -128), set);
    Assert.assertTrue(set.addAll(ByteHashSet.newSetWith((byte) 0, (byte) 1, (byte) 2, (byte) 30, (byte) -1, (byte) -128)));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 0, (byte) 1, (byte) 2, (byte) 30, (byte) 31, (byte) -1, (byte) -128), set);
    Assert.assertTrue(set.addAll(ByteHashSet.newSetWith((byte) 5)));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 0, (byte) 1, (byte) 2, (byte) 5, (byte) 30, (byte) 31, (byte) 31, (byte) -1, (byte) -128), set);
    ByteHashSet set1 = new ByteHashSet();
    Assert.assertTrue(set1.addAll((byte) 2, (byte) 35));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 2, (byte) 35), set1);
}
Also used : ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Example 17 with ByteArrayList

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

the class AbstractByteSetTestCase method removeAll_iterable.

@Override
@Test
public void removeAll_iterable() {
    super.removeAll_iterable();
    MutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) 63, (byte) 100, (byte) 127, (byte) -1, (byte) -35, (byte) -64, (byte) -100, (byte) -128);
    Assert.assertFalse(set.removeAll(new ByteArrayList()));
    Assert.assertFalse(set.removeAll(ByteArrayList.newListWith((byte) 15, (byte) 98, (byte) -98, (byte) -127)));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 0, (byte) 1, (byte) 31, (byte) 63, (byte) 100, (byte) 127, (byte) -1, (byte) -35, (byte) -64, (byte) -100, (byte) -128), set);
    Assert.assertTrue(set.removeAll(ByteHashSet.newSetWith((byte) 0, (byte) 31, (byte) -128, (byte) -100)));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 1, (byte) 63, (byte) 100, (byte) 127, (byte) -1, (byte) -35, (byte) -64), set);
    Assert.assertTrue(set.removeAll(ByteHashSet.newSetWith((byte) 1, (byte) 63, (byte) 100, (byte) 127, (byte) -1, (byte) -35, (byte) -64)));
    Assert.assertEquals(new ByteHashSet(), set);
    Assert.assertFalse(set.removeAll(ByteHashSet.newSetWith((byte) 1)));
    Assert.assertEquals(new ByteHashSet(), set);
}
Also used : ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Example 18 with ByteArrayList

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

the class ArrayIterateTest method collectByteWithTarget.

@Test
public void collectByteWithTarget() {
    Integer[] objectArray = { -1, 0, 42 };
    ByteArrayList target = new ByteArrayList();
    ByteArrayList result = ArrayIterate.collectByte(objectArray, PrimitiveFunctions.unboxIntegerToByte(), target);
    Assert.assertEquals(this.getExpectedByteResults(), result);
    Assert.assertSame("Target List not returned as result", target, result);
}
Also used : BigInteger(java.math.BigInteger) ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) Test(org.junit.Test)

Example 19 with ByteArrayList

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

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

the class TreeSortedSet method collectByte.

@Override
public MutableByteList collectByte(ByteFunction<? super T> byteFunction) {
    ByteArrayList result = new ByteArrayList(this.size());
    this.forEach(new CollectByteProcedure<>(byteFunction, result));
    return result;
}
Also used : ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)

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