use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.
the class AbstractMutableLongLongMapTestCase method addToValue.
@Test
public void addToValue() {
MutableLongLongMap map1 = this.getEmptyMap();
Assert.assertEquals(1L, map1.addToValue(0L, 1L));
Assert.assertEquals(32L, map1.addToValue(31L, 32L));
Assert.assertEquals(3L, map1.addToValue(1L, 3L));
Assert.assertEquals(11L, map1.addToValue(0L, 10L));
Assert.assertEquals(12L, map1.addToValue(1L, 9L));
Assert.assertEquals(37L, map1.addToValue(31L, 5L));
Assert.assertEquals(33L, map1.addToValue(32L, 33L));
LongLongHashMap expected = LongLongHashMap.newWithKeysValues(0L, 11L, 1L, 12L, 31L, 37L, 32L, 33L);
Assert.assertEquals(expected, map1);
map1.removeKey(0L);
map1.removeKey(1L);
map1.removeKey(31L);
map1.removeKey(32L);
Assert.assertEquals(5L, map1.addToValue(31L, 5L));
Assert.assertEquals(37L, map1.addToValue(31L, 32L));
Assert.assertEquals(33L, map1.addToValue(32L, 33L));
Assert.assertEquals(3L, map1.addToValue(1L, 3L));
Assert.assertEquals(1L, map1.addToValue(0L, 1L));
Assert.assertEquals(12L, map1.addToValue(1L, 9L));
Assert.assertEquals(11L, map1.addToValue(0L, 10L));
Assert.assertEquals(expected, map1);
}
use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.
the class AbstractMutableLongLongMapTestCase method getIfAbsentPut_Function.
@Test
public void getIfAbsentPut_Function() {
LongFunction0 factory = () -> 100L;
LongFunction0 factoryThrows = () -> {
throw new AssertionError();
};
MutableLongLongMap map1 = this.getEmptyMap();
Assert.assertEquals(100L, map1.getIfAbsentPut(0L, factory));
Assert.assertEquals(100L, map1.getIfAbsentPut(0L, factoryThrows));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 100L), map1);
Assert.assertEquals(100L, map1.getIfAbsentPut(1L, factory));
Assert.assertEquals(100L, map1.getIfAbsentPut(1L, factoryThrows));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 100L, 1L, 100L), map1);
MutableLongLongMap map2 = this.getEmptyMap();
Assert.assertEquals(100L, map2.getIfAbsentPut(1L, factory));
Assert.assertEquals(100L, map2.getIfAbsentPut(1L, factoryThrows));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(1L, 100L), map2);
Assert.assertEquals(100L, map2.getIfAbsentPut(0L, factory));
Assert.assertEquals(100L, map2.getIfAbsentPut(0L, factoryThrows));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 100L, 1L, 100L), map2);
MutableLongLongMap map3 = this.getEmptyMap();
Assert.assertEquals(100L, map3.getIfAbsentPut(32L, factory));
Assert.assertEquals(100L, map3.getIfAbsentPut(32L, factoryThrows));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(32L, 100L), map3);
MutableLongLongMap map4 = this.getEmptyMap();
Assert.assertEquals(100L, map4.getIfAbsentPut(33L, factory));
Assert.assertEquals(100L, map4.getIfAbsentPut(33L, factoryThrows));
Assert.assertEquals(LongLongHashMap.newWithKeysValues(33L, 100L), map4);
}
use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.
the class AbstractMutableLongLongMapTestCase method longIterator_with_remove.
@Test
public void longIterator_with_remove() {
MutableLongLongMap mutableMap = this.classUnderTest();
MutableLongIterator iterator = mutableMap.longIterator();
while (iterator.hasNext()) {
iterator.next();
iterator.remove();
}
Assert.assertFalse(iterator.hasNext());
Verify.assertEmpty(mutableMap);
Verify.assertThrows(NoSuchElementException.class, iterator::next);
}
use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.
the class AbstractMutableLongLongMapTestCase method remove.
@Test
public void remove() {
MutableLongLongMap map0 = this.newWithKeysValues(0L, 0L, 1L, 1L);
map0.remove(1L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 0L), map0);
map0.remove(0L);
Assert.assertEquals(new LongLongHashMap(), map0);
MutableLongLongMap map1 = this.newWithKeysValues(0L, 0L, 1L, 1L);
map1.remove(0L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(1L, 1L), map1);
map1.remove(1L);
Assert.assertEquals(new LongLongHashMap(), map1);
MutableLongLongMap map2 = this.classUnderTest();
map2.remove(5L);
map2.remove(50L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 0L, 31L, 31L, 32L, 32L), map2);
map2.remove(0L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(31L, 31L, 32L, 32L), map2);
map2.remove(31L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(32L, 32L), map2);
map2.remove(32L);
Assert.assertEquals(new LongLongHashMap(), map2);
map2.remove(0L);
map2.remove(31L);
map2.remove(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.remove(AbstractMutableLongLongMapTestCase.generateCollisions().get(0));
Assert.assertEquals(0L, map2.get(AbstractMutableLongLongMapTestCase.generateCollisions().get(0)));
Assert.assertEquals(2L, map2.get(AbstractMutableLongLongMapTestCase.generateCollisions().get(1)));
map2.remove(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 clear.
@Test
public void clear() {
MutableLongLongMap map1 = this.classUnderTest();
map1.clear();
Assert.assertEquals(new LongLongHashMap(), map1);
map1.put(1L, 0L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(1L, 0L), map1);
map1.clear();
Assert.assertEquals(new LongLongHashMap(), map1);
map1.put(33L, 0L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(33L, 0L), map1);
map1.clear();
Assert.assertEquals(new LongLongHashMap(), map1);
}
Aggregations