use of org.eclipse.collections.api.map.primitive.MutableLongLongMap 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());
}
use of org.eclipse.collections.api.map.primitive.MutableLongLongMap 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));
}
use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.
the class AbstractMutableLongLongMapTestCase method updateValue.
@Test
public void updateValue() {
LongToLongFunction incrementFunction = (long value) -> value + 1L;
MutableLongLongMap map1 = this.getEmptyMap();
Assert.assertEquals(1L, map1.updateValue(0L, 0L, incrementFunction));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 1L), map1);
Assert.assertEquals(2L, map1.updateValue(0L, 0L, incrementFunction));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 2L), map1);
Assert.assertEquals(1L, map1.updateValue(1L, 0L, incrementFunction));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 2L, 1L, 1L), map1);
Assert.assertEquals(2L, map1.updateValue(1L, 0L, incrementFunction));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 2L, 1L, 2L), map1);
MutableLongLongMap map2 = this.getEmptyMap();
Assert.assertEquals(1L, map2.updateValue(1L, 0L, incrementFunction));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(1L, 1L), map2);
Assert.assertEquals(2L, map2.updateValue(1L, 0L, incrementFunction));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(1L, 2L), map2);
Assert.assertEquals(1L, map2.updateValue(0L, 0L, incrementFunction));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 1L, 1L, 2L), map2);
Assert.assertEquals(2L, map2.updateValue(0L, 0L, incrementFunction));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 2L, 1L, 2L), map2);
MutableLongLongMap map3 = this.getEmptyMap();
Assert.assertEquals(1L, map3.updateValue(33L, 0L, incrementFunction));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(33L, 1L), map3);
Assert.assertEquals(2L, map3.updateValue(33L, 0L, incrementFunction));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(33L, 2L), map3);
}
use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.
the class AbstractMutableLongLongMapTestCase method withoutAllKeys.
@Test
public void withoutAllKeys() {
MutableLongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 31L, 31L, 32L, 32L);
MutableLongLongMap mapWithout = map.withoutAllKeys(LongArrayList.newListWith(0L, 32L));
Assert.assertSame(map, mapWithout);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(1L, 1L, 31L, 31L), mapWithout);
}
use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.
the class AbstractMutableLongLongMapTestCase method getIfAbsent.
@Override
@Test
public void getIfAbsent() {
super.getIfAbsent();
MutableLongLongMap map1 = this.classUnderTest();
map1.removeKey(0L);
Assert.assertEquals(5L, map1.getIfAbsent(0L, 5L));
Assert.assertEquals(6L, map1.getIfAbsent(1L, 6L));
Assert.assertEquals(6L, map1.getIfAbsent(33L, 6L));
map1.put(0L, 1L);
Assert.assertEquals(1L, map1.getIfAbsent(0L, 5L));
map1.put(1L, 1L);
Assert.assertEquals(1L, map1.getIfAbsent(1L, 5L));
map1.put(5L, 5L);
Assert.assertEquals(5L, map1.getIfAbsent(5L, 6L));
map1.put(35L, 35L);
Assert.assertEquals(35L, map1.getIfAbsent(35L, 5L));
}
Aggregations