Search in sources :

Example 11 with LongArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.LongArrayList in project mapdb by jankotek.

the class AbstractMutableLongCollectionTestCase method removeAll_iterable.

@Test
public void removeAll_iterable() {
    MutableLongCollection collection = this.classUnderTest();
    Assert.assertFalse(collection.removeAll(this.newMutableCollectionWith()));
    Assert.assertFalse(collection.removeAll(this.newMutableCollectionWith(-1L)));
    Assert.assertEquals(this.newMutableCollectionWith(1L, 2L, 3L), collection);
    Assert.assertTrue(collection.removeAll(this.newMutableCollectionWith(1L, 5L)));
    Assert.assertEquals(this.newMutableCollectionWith(2L, 3L), collection);
    MutableLongCollection collection1 = this.classUnderTest();
    Assert.assertTrue(collection1.removeAll(this.newMutableCollectionWith(3L, 2L)));
    Assert.assertEquals(this.newMutableCollectionWith(1L), collection1);
    MutableLongCollection collection2 = this.newWith(0L, 1L, 1L, 2L, 2L, 2L, 3L);
    Assert.assertFalse(collection2.removeAll(new LongArrayList()));
    Assert.assertTrue(collection2.removeAll(LongArrayList.newListWith(0L, 1L)));
    Assert.assertEquals(this.newMutableCollectionWith(2L, 2L, 2L, 3L), collection2);
    Assert.assertFalse(collection2.removeAll(LongArrayList.newListWith(0L)));
    Assert.assertTrue(collection2.removeAll(LongArrayList.newListWith(2L)));
    Assert.assertEquals(this.newMutableCollectionWith(3L), collection2);
    MutableLongCollection collection3 = this.newWith(0L, 1L, 1L, 2L, 2L, 2L);
    Assert.assertTrue(collection3.removeAll(LongHashBag.newBagWith(0L, 1L, 1L)));
    Assert.assertEquals(this.newMutableCollectionWith(2L, 2L, 2L), collection3);
}
Also used : LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) Test(org.junit.Test)

Example 12 with LongArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.LongArrayList in project mapdb by jankotek.

the class AbstractMutableLongCollectionTestCase method retainAll_iterable.

@Test
public void retainAll_iterable() {
    MutableLongCollection collection = this.classUnderTest();
    Assert.assertFalse(collection.retainAll(this.newMutableCollectionWith(1L, 2L, 3L)));
    Assert.assertEquals(this.newMutableCollectionWith(1L, 2L, 3L), collection);
    Assert.assertTrue(collection.retainAll(this.newMutableCollectionWith(1L, 2L, 5L)));
    Assert.assertEquals(this.newMutableCollectionWith(1L, 2L), collection);
    MutableLongCollection collection1 = this.classUnderTest();
    Assert.assertTrue(collection1.retainAll(this.newMutableCollectionWith(-3L, 1L)));
    Assert.assertEquals(this.newMutableCollectionWith(1L), collection1);
    Assert.assertTrue(collection1.retainAll(this.newMutableCollectionWith(-1L)));
    Verify.assertEmpty(collection1);
    MutableLongCollection collection2 = this.newWith(0L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L);
    Assert.assertFalse(collection2.retainAll(this.newMutableCollectionWith(0L, 1L, 2L, 3L)));
    Assert.assertTrue(collection2.retainAll(LongArrayList.newListWith(0L, 1L, 3L)));
    Assert.assertEquals(this.newMutableCollectionWith(0L, 1L, 1L, 3L, 3L, 3L), collection2);
    Assert.assertFalse(collection2.retainAll(LongArrayList.newListWith(0L, 1L, 3L)));
    Assert.assertTrue(collection2.retainAll(LongArrayList.newListWith(5L, 3L)));
    Assert.assertEquals(this.newMutableCollectionWith(3L, 3L, 3L), collection2);
    MutableLongCollection collection3 = this.newWith(0L, 1L, 1L, 2L, 2L, 2L);
    Assert.assertTrue(collection3.retainAll(LongHashBag.newBagWith(2L, 8L, 8L, 2L)));
    Assert.assertEquals(this.newMutableCollectionWith(2L, 2L, 2L), collection3);
    MutableLongCollection collection4 = this.classUnderTest();
    Assert.assertTrue(collection4.retainAll(new LongArrayList()));
    Verify.assertEmpty(collection4);
}
Also used : LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) Test(org.junit.Test)

Aggregations

LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)12 Test (org.junit.Test)9 MutableLongCollection (org.eclipse.collections.api.collection.primitive.MutableLongCollection)5 LongHashSet (org.eclipse.collections.impl.set.mutable.primitive.LongHashSet)4 LazyLongIterable (org.eclipse.collections.api.LazyLongIterable)2 LongIterable (org.eclipse.collections.api.LongIterable)2 MutableLongLongMap (org.eclipse.collections.api.map.primitive.MutableLongLongMap)2 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)2 LongIterator (org.eclipse.collections.api.iterator.LongIterator)1 LongLongHashMap (org.eclipse.collections.impl.map.mutable.primitive.LongLongHashMap)1