Search in sources :

Example 6 with MutableByteSet

use of org.eclipse.collections.api.set.primitive.MutableByteSet in project eclipse-collections by eclipse.

the class AbstractByteSetTestCase method toSortedArray.

@Override
@Test
public void toSortedArray() {
    super.toSortedArray();
    MutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) -1, (byte) -123, (byte) -53);
    Assert.assertArrayEquals(new byte[] { (byte) -123, (byte) -53, (byte) -1, (byte) 0, (byte) 1, (byte) 31 }, set.toSortedArray());
}
Also used : MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Example 7 with MutableByteSet

use of org.eclipse.collections.api.set.primitive.MutableByteSet in project eclipse-collections by eclipse.

the class AbstractByteSetTestCase method remove.

@Override
@Test
public void remove() {
    super.remove();
    MutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) -1, (byte) -8);
    Assert.assertFalse(this.newWith().remove((byte) 15));
    Assert.assertFalse(set.remove((byte) 15));
    Assert.assertTrue(set.remove((byte) 0));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 1, (byte) 31, (byte) -1, (byte) -8), set);
    Assert.assertFalse(set.remove((byte) -10));
    Assert.assertFalse(set.remove((byte) -7));
    Assert.assertTrue(set.remove((byte) -1));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 1, (byte) 31, (byte) -8), set);
    Assert.assertTrue(set.remove((byte) -8));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 1, (byte) 31), set);
    Assert.assertTrue(set.remove((byte) 31));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 1), set);
    Assert.assertTrue(set.remove((byte) 1));
    Assert.assertEquals(ByteHashSet.newSetWith(), set);
}
Also used : MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Example 8 with MutableByteSet

use of org.eclipse.collections.api.set.primitive.MutableByteSet in project eclipse-collections by eclipse.

the class AbstractByteSetTestCase method removeAll.

@Override
@Test
public void removeAll() {
    super.removeAll();
    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());
    Assert.assertFalse(set.removeAll((byte) 15, (byte) -5, (byte) -32));
    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((byte) 0, (byte) 1, (byte) -1, (byte) -128));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 31, (byte) 63, (byte) 100, (byte) 127, (byte) -35, (byte) -64, (byte) -100), set);
    Assert.assertTrue(set.removeAll((byte) 31, (byte) 63, (byte) 14, (byte) -100));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 100, (byte) 127, (byte) -35, (byte) -64), set);
    Assert.assertFalse(set.removeAll((byte) -34, (byte) -36, (byte) -63, (byte) -65, (byte) 99, (byte) 101, (byte) 126, (byte) 128));
    Assert.assertEquals(ByteHashSet.newSetWith((byte) 100, (byte) 127, (byte) -35, (byte) -64), set);
    Assert.assertTrue(set.removeAll((byte) -35, (byte) -63, (byte) -64, (byte) 100, (byte) 127));
    Assert.assertEquals(new ByteHashSet(), set);
}
Also used : MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Example 9 with MutableByteSet

use of org.eclipse.collections.api.set.primitive.MutableByteSet in project eclipse-collections by eclipse.

the class AbstractByteSetTestCase method collect.

@Override
@Test
public void collect() {
    super.collect();
    MutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) -127, (byte) -63);
    Assert.assertEquals(UnifiedSet.newSetWith((byte) -1, (byte) 0, (byte) 30, (byte) -128, (byte) -64), set.collect(byteParameter -> (byte) (byteParameter - 1)));
}
Also used : LazyByteIterable(org.eclipse.collections.api.LazyByteIterable) MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) ByteHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag) Test(org.junit.Test) Verify(org.eclipse.collections.impl.test.Verify) MutableSet(org.eclipse.collections.api.set.MutableSet) ByteSets(org.eclipse.collections.impl.factory.primitive.ByteSets) ByteIterator(org.eclipse.collections.api.iterator.ByteIterator) AbstractMutableByteCollectionTestCase(org.eclipse.collections.impl.collection.mutable.primitive.AbstractMutableByteCollectionTestCase) NoSuchElementException(java.util.NoSuchElementException) Assert(org.junit.Assert) BytePredicates(org.eclipse.collections.impl.block.factory.primitive.BytePredicates) UnifiedSet(org.eclipse.collections.impl.set.mutable.UnifiedSet) MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Example 10 with MutableByteSet

use of org.eclipse.collections.api.set.primitive.MutableByteSet in project eclipse-collections by eclipse.

the class AbstractByteSetTestCase method reject.

@Override
@Test
public void reject() {
    super.reject();
    MutableByteSet set = this.newWith((byte) 0, (byte) 1, (byte) 31, (byte) -1, (byte) -127, (byte) -63);
    Assert.assertEquals(this.newWith((byte) 0, (byte) -1, (byte) -127, (byte) -63), set.reject(BytePredicates.greaterThan((byte) 0)));
    Assert.assertEquals(this.newWith((byte) 0, (byte) 1, (byte) 31), set.reject(BytePredicates.lessThan((byte) 0)));
}
Also used : MutableByteSet(org.eclipse.collections.api.set.primitive.MutableByteSet) Test(org.junit.Test)

Aggregations

MutableByteSet (org.eclipse.collections.api.set.primitive.MutableByteSet)25 Test (org.junit.Test)21 ByteIterator (org.eclipse.collections.api.iterator.ByteIterator)4 ByteArrayList (org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)3 LazyByteIterable (org.eclipse.collections.api.LazyByteIterable)2 ByteHashSet (org.eclipse.collections.impl.set.mutable.primitive.ByteHashSet)2 NoSuchElementException (java.util.NoSuchElementException)1 ByteIterable (org.eclipse.collections.api.ByteIterable)1 MutableByteIterator (org.eclipse.collections.api.iterator.MutableByteIterator)1 MutableSet (org.eclipse.collections.api.set.MutableSet)1 ByteHashBag (org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag)1 BytePredicates (org.eclipse.collections.impl.block.factory.primitive.BytePredicates)1 AbstractMutableByteCollectionTestCase (org.eclipse.collections.impl.collection.mutable.primitive.AbstractMutableByteCollectionTestCase)1 ByteSets (org.eclipse.collections.impl.factory.primitive.ByteSets)1 UnifiedSet (org.eclipse.collections.impl.set.mutable.UnifiedSet)1 Verify (org.eclipse.collections.impl.test.Verify)1 Assert (org.junit.Assert)1