use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.
the class LongLongHashMapValuesTest method longIterator.
@Override
@Test
public void longIterator() {
MutableLongCollection bag = this.newWith(0L, 1L, 2L, 3L);
LongArrayList list = LongArrayList.newListWith(0L, 1L, 2L, 3L);
LongIterator iterator = bag.longIterator();
for (int i = 0; i < 4; i++) {
Assert.assertTrue(iterator.hasNext());
Assert.assertTrue(list.remove(iterator.next()));
}
Verify.assertEmpty(list);
Assert.assertFalse(iterator.hasNext());
Verify.assertThrows(NoSuchElementException.class, iterator::next);
}
use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.
the class LongLongHashMapValuesTest method removeAll.
@Override
@Test
public void removeAll() {
Assert.assertFalse(this.newWith().removeAll());
Assert.assertFalse(this.newWith().removeAll(1L));
MutableLongLongMap map = newWithKeysValues(1L, 1L, 2L, 2L, 3L, 3L);
MutableLongCollection collection = map.values();
Assert.assertFalse(collection.removeAll());
Assert.assertTrue(collection.removeAll(1L, 5L));
Assert.assertFalse(collection.contains(1L));
Assert.assertTrue(collection.contains(2L));
Assert.assertTrue(collection.contains(3L));
Assert.assertFalse(map.contains(1L));
Assert.assertTrue(map.contains(2L));
Assert.assertTrue(map.contains(3L));
Assert.assertTrue(collection.removeAll(3L, 2L));
Assert.assertTrue(collection.isEmpty());
Assert.assertFalse(collection.contains(1L));
Assert.assertFalse(collection.contains(2L));
Assert.assertFalse(collection.contains(3L));
Assert.assertFalse(map.contains(1L));
Assert.assertFalse(map.contains(2L));
Assert.assertFalse(map.contains(3L));
Assert.assertTrue(map.isEmpty());
}
use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.
the class LongLongHashMapValuesTest method retainAll_iterable.
@Override
@Test
public void retainAll_iterable() {
Assert.assertFalse(this.newWith().retainAll(new LongArrayList()));
Assert.assertFalse(this.newWith().retainAll(LongArrayList.newListWith(1L)));
MutableLongLongMap map = newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
MutableLongCollection collection = map.values();
Assert.assertFalse(collection.retainAll(LongArrayList.newListWith(0L, 1L, 2L, 3L)));
Assert.assertTrue(collection.retainAll(LongArrayList.newListWith(0L, 2L, 3L, 5L)));
Assert.assertTrue(collection.contains(0L));
Assert.assertFalse(collection.contains(1L));
Assert.assertTrue(collection.contains(2L));
Assert.assertTrue(collection.contains(3L));
Assert.assertFalse(collection.contains(5L));
Assert.assertTrue(map.contains(0L));
Assert.assertFalse(map.contains(1L));
Assert.assertTrue(map.contains(2L));
Assert.assertTrue(map.contains(3L));
Assert.assertFalse(map.contains(5L));
Assert.assertTrue(collection.retainAll(LongArrayList.newListWith(2L, 3L, 5L)));
Assert.assertFalse(collection.contains(0L));
Assert.assertFalse(collection.contains(1L));
Assert.assertTrue(collection.contains(2L));
Assert.assertTrue(collection.contains(3L));
Assert.assertFalse(collection.contains(5L));
Assert.assertFalse(map.contains(0L));
Assert.assertFalse(map.contains(1L));
Assert.assertTrue(map.contains(2L));
Assert.assertTrue(map.contains(3L));
Assert.assertFalse(map.contains(5L));
Assert.assertTrue(collection.retainAll(LongArrayList.newListWith(3L, 5L)));
Assert.assertFalse(collection.contains(0L));
Assert.assertFalse(collection.contains(1L));
Assert.assertFalse(collection.contains(2L));
Assert.assertTrue(collection.contains(3L));
Assert.assertFalse(collection.contains(5L));
Assert.assertFalse(map.contains(0L));
Assert.assertFalse(map.contains(1L));
Assert.assertFalse(map.contains(2L));
Assert.assertTrue(map.contains(3L));
Assert.assertFalse(map.contains(5L));
Assert.assertTrue(collection.retainAll(LongArrayList.newListWith(0L, 0L, 1L)));
Assert.assertTrue(collection.isEmpty());
Assert.assertFalse(collection.contains(0L));
Assert.assertFalse(collection.contains(1L));
Assert.assertFalse(collection.contains(2L));
Assert.assertFalse(collection.contains(3L));
Assert.assertFalse(collection.contains(5L));
Assert.assertFalse(map.contains(0L));
Assert.assertFalse(map.contains(1L));
Assert.assertFalse(map.contains(2L));
Assert.assertFalse(map.contains(3L));
Assert.assertFalse(map.contains(5L));
Assert.assertTrue(map.isEmpty());
}
use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.
the class AbstractMutableLongCollectionTestCase method asSynchronized.
@Test
public void asSynchronized() {
MutableLongCollection collection = this.classUnderTest();
Assert.assertEquals(collection, collection.asSynchronized());
Verify.assertInstanceOf(this.newWith(1L, 2L, 3L).asSynchronized().getClass(), this.classUnderTest().asSynchronized());
MutableLongCollection collection1 = this.newWith(1L, 2L, 2L, 3L, 3L, 3L);
MutableLongCollection synchronizedCollection = this.newWith(1L, 2L, 2L, 3L, 3L, 3L).asSynchronized();
Verify.assertInstanceOf(synchronizedCollection.getClass(), collection1.asSynchronized());
Assert.assertEquals(synchronizedCollection, collection1.asSynchronized());
}
use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.
the class AbstractMutableLongCollectionTestCase method retainAll.
@Test
public void retainAll() {
MutableLongCollection collection = this.classUnderTest();
Assert.assertFalse(collection.retainAll(1L, 2L, 3L));
Assert.assertEquals(this.newMutableCollectionWith(1L, 2L, 3L), collection);
Assert.assertTrue(collection.retainAll(1L, 2L, 5L));
Assert.assertEquals(this.newMutableCollectionWith(1L, 2L), collection);
MutableLongCollection collection1 = this.classUnderTest();
Assert.assertTrue(collection1.retainAll(-3L, 1L));
Assert.assertEquals(this.newMutableCollectionWith(1L), collection1);
Assert.assertTrue(collection1.retainAll(-1L));
Verify.assertEmpty(collection1);
MutableLongCollection collection2 = this.newWith(0L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L);
Assert.assertFalse(collection2.retainAll(0L, 1L, 2L, 3L));
Assert.assertTrue(collection2.retainAll(0L, 1L, 3L));
Assert.assertEquals(this.newMutableCollectionWith(0L, 1L, 1L, 3L, 3L, 3L), collection2);
Assert.assertFalse(collection2.retainAll(0L, 1L, 3L));
Assert.assertTrue(collection2.retainAll(5L, 3L));
Assert.assertEquals(this.newMutableCollectionWith(3L, 3L, 3L), collection2);
MutableLongCollection collection3 = this.newWith(0L, 1L, 1L, 2L, 2L, 2L);
Assert.assertTrue(collection3.retainAll(2L, 8L, 8L, 2L));
Assert.assertEquals(this.newMutableCollectionWith(2L, 2L, 2L), collection3);
MutableLongCollection collection4 = this.classUnderTest();
Assert.assertTrue(collection4.retainAll());
Verify.assertEmpty(collection4);
}
Aggregations