use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.
the class AbstractMutableLongLongMapTestCase method removeKeyIfAbsent.
@Test
public void removeKeyIfAbsent() {
MutableLongLongMap map0 = this.newWithKeysValues(0L, 0L, 1L, 1L);
Assert.assertEquals(1L, map0.removeKeyIfAbsent(1L, 100L));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 0L), map0);
Assert.assertEquals(0L, map0.removeKeyIfAbsent(0L, 100L));
Assert.assertEquals(new LongLongHashMap(), map0);
Assert.assertEquals(100L, map0.removeKeyIfAbsent(1L, 100L));
Assert.assertEquals(100L, map0.removeKeyIfAbsent(0L, 100L));
MutableLongLongMap map1 = this.newWithKeysValues(0L, 0L, 1L, 1L);
Assert.assertEquals(0L, map1.removeKeyIfAbsent(0L, 100L));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(1L, 1L), map1);
Assert.assertEquals(1L, map1.removeKeyIfAbsent(1L, 100L));
Assert.assertEquals(new LongLongHashMap(), map1);
Assert.assertEquals(100L, map1.removeKeyIfAbsent(0L, 100L));
Assert.assertEquals(100L, map1.removeKeyIfAbsent(1L, 100L));
MutableLongLongMap map2 = this.classUnderTest();
Assert.assertEquals(100L, map2.removeKeyIfAbsent(5L, 100L));
Assert.assertEquals(100L, map2.removeKeyIfAbsent(50L, 100L));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 0L, 31L, 31L, 32L, 32L), map2);
Assert.assertEquals(0L, map2.removeKeyIfAbsent(0L, 100L));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(31L, 31L, 32L, 32L), map2);
Assert.assertEquals(31L, map2.removeKeyIfAbsent(31L, 100L));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(32L, 32L), map2);
Assert.assertEquals(32L, map2.removeKeyIfAbsent(32L, 100L));
Assert.assertEquals(new LongLongHashMap(), map2);
Assert.assertEquals(100L, map2.removeKeyIfAbsent(0L, 100L));
Assert.assertEquals(100L, map2.removeKeyIfAbsent(31L, 100L));
Assert.assertEquals(100L, map2.removeKeyIfAbsent(32L, 100L));
Assert.assertEquals(new LongLongHashMap(), map2);
Verify.assertEmpty(map2);
map2.put(AbstractMutableLongLongMapTestCase.generateCollisions().get(0), 1L);
map2.put(AbstractMutableLongLongMapTestCase.generateCollisions().get(1), 2L);
Assert.assertEquals(1L, map2.get(AbstractMutableLongLongMapTestCase.generateCollisions().get(0)));
Assert.assertEquals(1L, map2.removeKeyIfAbsent(AbstractMutableLongLongMapTestCase.generateCollisions().get(0), 100L));
Assert.assertEquals(0L, map2.get(AbstractMutableLongLongMapTestCase.generateCollisions().get(0)));
Assert.assertEquals(2L, map2.get(AbstractMutableLongLongMapTestCase.generateCollisions().get(1)));
Assert.assertEquals(2L, map2.removeKeyIfAbsent(AbstractMutableLongLongMapTestCase.generateCollisions().get(1), 100L));
Assert.assertEquals(0L, map2.get(AbstractMutableLongLongMapTestCase.generateCollisions().get(1)));
}
use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.
the class AbstractMutableLongLongMapTestCase method put.
@Test
public void put() {
MutableLongLongMap map1 = this.classUnderTest();
map1.put(0L, 1L);
map1.put(31L, 32L);
map1.put(32L, 33L);
LongLongHashMap expected = LongLongHashMap.newWithKeysValues(0L, 1L, 31L, 32L, 32L, 33L);
Assert.assertEquals(expected, map1);
map1.put(1L, 2L);
expected.put(1L, 2L);
Assert.assertEquals(expected, map1);
map1.put(33L, 34L);
expected.put(33L, 34L);
Assert.assertEquals(expected, map1);
map1.put(30L, 31L);
expected.put(30L, 31L);
Assert.assertEquals(expected, map1);
}
use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.
the class AbstractMutableLongLongMapTestCase method removeKey.
@Test
public void removeKey() {
MutableLongLongMap map0 = this.newWithKeysValues(0L, 0L, 1L, 1L);
map0.removeKey(1L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 0L), map0);
map0.removeKey(0L);
Assert.assertEquals(new LongLongHashMap(), map0);
MutableLongLongMap map1 = this.newWithKeysValues(0L, 0L, 1L, 1L);
map1.removeKey(0L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(1L, 1L), map1);
map1.removeKey(1L);
Assert.assertEquals(new LongLongHashMap(), map1);
MutableLongLongMap map2 = this.classUnderTest();
map2.removeKey(5L);
map2.removeKey(50L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 0L, 31L, 31L, 32L, 32L), map2);
map2.removeKey(0L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(31L, 31L, 32L, 32L), map2);
map2.removeKey(31L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(32L, 32L), map2);
map2.removeKey(32L);
Assert.assertEquals(new LongLongHashMap(), map2);
map2.removeKey(0L);
map2.removeKey(31L);
map2.removeKey(32L);
Assert.assertEquals(new LongLongHashMap(), map2);
Verify.assertEmpty(map2);
map2.put(AbstractMutableLongLongMapTestCase.generateCollisions().get(0), 1L);
map2.put(AbstractMutableLongLongMapTestCase.generateCollisions().get(1), 2L);
Assert.assertEquals(1L, map2.get(AbstractMutableLongLongMapTestCase.generateCollisions().get(0)));
map2.removeKey(AbstractMutableLongLongMapTestCase.generateCollisions().get(0));
Assert.assertEquals(0L, map2.get(AbstractMutableLongLongMapTestCase.generateCollisions().get(0)));
Assert.assertEquals(2L, map2.get(AbstractMutableLongLongMapTestCase.generateCollisions().get(1)));
map2.removeKey(AbstractMutableLongLongMapTestCase.generateCollisions().get(1));
Assert.assertEquals(0L, map2.get(AbstractMutableLongLongMapTestCase.generateCollisions().get(1)));
}
use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.
the class AbstractMutableLongLongMapTestCase method putDuplicateWithRemovedSlot.
@Test
public void putDuplicateWithRemovedSlot() {
long collision1 = AbstractMutableLongLongMapTestCase.generateCollisions().getFirst();
long collision2 = AbstractMutableLongLongMapTestCase.generateCollisions().get(1);
long collision3 = AbstractMutableLongLongMapTestCase.generateCollisions().get(2);
long collision4 = AbstractMutableLongLongMapTestCase.generateCollisions().get(3);
MutableLongLongMap hashMap = this.getEmptyMap();
hashMap.put(collision1, 1L);
hashMap.put(collision2, 2L);
hashMap.put(collision3, 3L);
Assert.assertEquals(2L, hashMap.get(collision2));
hashMap.removeKey(collision2);
hashMap.put(collision4, 4L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(collision1, 1L, collision3, 3L, collision4, 4L), hashMap);
MutableLongLongMap hashMap1 = this.getEmptyMap();
hashMap1.put(collision1, 1L);
hashMap1.put(collision2, 2L);
hashMap1.put(collision3, 3L);
Assert.assertEquals(1L, hashMap1.get(collision1));
hashMap1.removeKey(collision1);
hashMap1.put(collision4, 4L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(collision2, 2L, collision3, 3L, collision4, 4L), hashMap1);
MutableLongLongMap hashMap2 = this.getEmptyMap();
hashMap2.put(collision1, 1L);
hashMap2.put(collision2, 2L);
hashMap2.put(collision3, 3L);
Assert.assertEquals(3L, hashMap2.get(collision3));
hashMap2.removeKey(collision3);
hashMap2.put(collision4, 4L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(collision1, 1L, collision2, 2L, collision4, 4L), hashMap2);
}
use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.
the class AbstractMutableLongLongMapTestCase method containsValue.
@Override
@Test
public void containsValue() {
super.containsValue();
MutableLongLongMap map1 = this.classUnderTest();
map1.put(35L, 35L);
Assert.assertTrue(map1.containsValue(35L));
map1.removeKey(0L);
Assert.assertFalse(map1.containsValue(0L));
}
Aggregations