Search in sources :

Example 16 with MutableLongCollection

use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.

the class LongLongHashMapValuesTest method contains.

@Override
@Test
public void contains() {
    MutableLongCollection collection = this.newWith(14L, 2L, 30L, 31L, 32L, 35L, 0L, 1L);
    Assert.assertFalse(collection.contains(29L));
    Assert.assertFalse(collection.contains(49L));
    long[] numbers = { 14L, 2L, 30L, 31L, 32L, 35L, 0L, 1L };
    for (long number : numbers) {
        Assert.assertTrue(collection.contains(number));
        Assert.assertTrue(collection.remove(number));
        Assert.assertFalse(collection.contains(number));
    }
    Assert.assertFalse(collection.contains(29L));
    Assert.assertFalse(collection.contains(49L));
}
Also used : MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) Test(org.junit.Test)

Example 17 with MutableLongCollection

use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.

the class LongLongHashMapValuesTest method asSynchronized.

@Override
@Test
@Ignore
public void asSynchronized() {
    MutableLongCollection collection = this.classUnderTest();
    Verify.assertInstanceOf(SynchronizedLongCollection.class, collection.asSynchronized());
    Assert.assertTrue(collection.asSynchronized().containsAll(this.classUnderTest()));
}
Also used : MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 18 with MutableLongCollection

use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.

the class LongLongHashMapValuesTest method retainAll.

@Override
@Test
public void retainAll() {
    Assert.assertFalse(this.newWith().retainAll());
    Assert.assertFalse(this.newWith().retainAll(1L));
    MutableLongLongMap map = newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
    MutableLongCollection collection = map.values();
    Assert.assertFalse(collection.retainAll(0L, 1L, 2L, 3L));
    Assert.assertTrue(collection.retainAll(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(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(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(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());
}
Also used : MutableLongLongMap(org.eclipse.collections.api.map.primitive.MutableLongLongMap) MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) Test(org.junit.Test)

Example 19 with MutableLongCollection

use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.

the class LongLongHashMapValuesTest method remove.

@Override
@Test
public void remove() {
    MutableLongLongMap map = newWithKeysValues(1L, 1L, 2L, 2L, 3L, 3L);
    MutableLongCollection collection = map.values();
    Assert.assertTrue(collection.remove(3L));
    Assert.assertFalse(collection.contains(3L));
    Assert.assertTrue(collection.contains(1L));
    Assert.assertTrue(collection.contains(2L));
    Assert.assertFalse(map.contains(3L));
    Assert.assertTrue(map.contains(1L));
    Assert.assertTrue(map.contains(2L));
}
Also used : MutableLongLongMap(org.eclipse.collections.api.map.primitive.MutableLongLongMap) MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) Test(org.junit.Test)

Example 20 with MutableLongCollection

use of org.eclipse.collections.api.collection.primitive.MutableLongCollection in project mapdb by jankotek.

the class AbstractMutableLongCollectionTestCase method longIterator_with_remove.

@Test
public void longIterator_with_remove() {
    MutableLongCollection longIterable = this.newWith(0L, 1L, 31L, 32L);
    final MutableLongIterator iterator = longIterable.longIterator();
    while (iterator.hasNext()) {
        iterator.next();
        iterator.remove();
    }
    Verify.assertEmpty(longIterable);
    Verify.assertThrows(NoSuchElementException.class, new Runnable() {

        @Override
        public void run() {
            iterator.next();
        }
    });
}
Also used : MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) MutableLongIterator(org.eclipse.collections.api.iterator.MutableLongIterator) Test(org.junit.Test)

Aggregations

MutableLongCollection (org.eclipse.collections.api.collection.primitive.MutableLongCollection)30 Test (org.junit.Test)30 MutableLongLongMap (org.eclipse.collections.api.map.primitive.MutableLongLongMap)6 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)5 MutableLongIterator (org.eclipse.collections.api.iterator.MutableLongIterator)4 LongIterator (org.eclipse.collections.api.iterator.LongIterator)2 Ignore (org.junit.Ignore)2