Search in sources :

Example 1 with LongArrayList

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

the class LongLongHashMapValuesTest method removeAll_iterable.

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

Example 2 with LongArrayList

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

the class AbstractLongIterableTestCase method containsAllIterable.

@Test
public void containsAllIterable() {
    LongIterable source = this.classUnderTest();
    Assert.assertTrue(source.containsAll(this.classUnderTest()));
    Assert.assertFalse(source.containsAll(LongArrayList.newListWith(source.size() + 1)));
    LongIterable iterable = this.newWith(1L, 2L, 3L);
    Assert.assertTrue(this.newWith().containsAll(new LongArrayList()));
    Assert.assertFalse(this.newWith().containsAll(LongArrayList.newListWith(1L)));
    Assert.assertTrue(iterable.containsAll(LongArrayList.newListWith(1L)));
    Assert.assertTrue(iterable.containsAll(LongArrayList.newListWith(1L, 2L, 3L)));
    Assert.assertFalse(iterable.containsAll(LongArrayList.newListWith(1L, 2L, 3L, 4L)));
    Assert.assertFalse(iterable.containsAll(LongArrayList.newListWith(1L, 2L, 4L)));
    Assert.assertFalse(iterable.containsAll(LongArrayList.newListWith(4L, 5L, 6L)));
    LongIterable iterable1 = this.newWith(14L, 2L, 30L, 32L, 35L, 0L, 1L);
    Assert.assertTrue(iterable1.containsAll(LongHashSet.newSetWith(14L)));
    Assert.assertTrue(iterable1.containsAll(LongHashSet.newSetWith(35L)));
    Assert.assertFalse(iterable1.containsAll(LongHashSet.newSetWith(-1L)));
    Assert.assertTrue(iterable1.containsAll(LongHashSet.newSetWith(14L, 1L, 30L)));
    Assert.assertTrue(iterable1.containsAll(LongHashSet.newSetWith(14L, 1L, 32L)));
    Assert.assertTrue(iterable1.containsAll(LongHashSet.newSetWith(14L, 1L, 35L)));
    Assert.assertFalse(iterable1.containsAll(LongHashSet.newSetWith(0L, 2L, 35L, -1L)));
    Assert.assertFalse(iterable1.containsAll(LongHashSet.newSetWith(31L, -1L)));
    LongIterable iterable2 = this.newWith(0L, 1L, 1L, 2L, 2L, 2L);
    Assert.assertTrue(iterable2.containsAll(LongArrayList.newListWith(0L)));
    Assert.assertTrue(iterable2.containsAll(LongArrayList.newListWith(0L, 0L, 0L)));
    Assert.assertTrue(iterable2.containsAll(LongArrayList.newListWith(0L, 1L, 1L)));
    Assert.assertTrue(iterable2.containsAll(LongArrayList.newListWith(0L, 1L, 2L)));
    Assert.assertFalse(iterable2.containsAll(LongArrayList.newListWith(0L, 1L, 2L, 3L, 4L)));
    Assert.assertFalse(iterable2.containsAll(LongArrayList.newListWith(3L, 4L)));
}
Also used : LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 3 with LongArrayList

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

the class AbstractLongIterableTestCase method toList.

@Test
public void toList() {
    LongIterable iterable = this.newWith(31L, 32L);
    Assert.assertTrue(LongArrayList.newListWith(31L, 32L).equals(iterable.toList()) || LongArrayList.newListWith(32L, 31L).equals(iterable.toList()));
    Assert.assertEquals(LongArrayList.newListWith(0L), this.newWith(0L).toList());
    Assert.assertEquals(LongArrayList.newListWith(31L), this.newWith(31L).toList());
    Assert.assertEquals(LongArrayList.newListWith(32L), this.newWith(32L).toList());
    Assert.assertEquals(new LongArrayList(), this.newWith().toList());
}
Also used : LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 4 with LongArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.LongArrayList 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);
}
Also used : LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) MutableLongCollection(org.eclipse.collections.api.collection.primitive.MutableLongCollection) LongIterator(org.eclipse.collections.api.iterator.LongIterator) Test(org.junit.Test)

Example 5 with LongArrayList

use of org.eclipse.collections.impl.list.mutable.primitive.LongArrayList 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());
}
Also used : LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) MutableLongLongMap(org.eclipse.collections.api.map.primitive.MutableLongLongMap) 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