Search in sources :

Example 26 with MutableLongLongMap

use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.

the class AbstractMutableLongLongMapTestCase method contains.

@Override
@Test
public void contains() {
    super.contains();
    MutableLongLongMap map1 = this.classUnderTest();
    map1.put(35L, 35L);
    Assert.assertTrue(map1.contains(35L));
    map1.removeKey(0L);
    Assert.assertFalse(map1.contains(0L));
}
Also used : MutableLongLongMap(org.eclipse.collections.api.map.primitive.MutableLongLongMap) Test(org.junit.Test)

Example 27 with MutableLongLongMap

use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.

the class AbstractMutableLongLongMapTestCase method containsKey.

@Override
@Test
public void containsKey() {
    super.containsKey();
    MutableLongLongMap map1 = this.classUnderTest();
    map1.removeKey(0L);
    Assert.assertFalse(map1.containsKey(0L));
    Assert.assertEquals(0L, map1.get(0L));
    map1.removeKey(0L);
    Assert.assertFalse(map1.containsKey(0L));
    Assert.assertEquals(0L, map1.get(0L));
    map1.removeKey(1L);
    Assert.assertFalse(map1.containsKey(1L));
    Assert.assertEquals(0L, map1.get(1L));
    map1.removeKey(31L);
    Assert.assertFalse(map1.containsKey(31L));
    Assert.assertEquals(0L, map1.get(31L));
    map1.removeKey(32L);
    Assert.assertFalse(map1.containsKey(32L));
    Assert.assertEquals(0L, map1.get(32L));
}
Also used : MutableLongLongMap(org.eclipse.collections.api.map.primitive.MutableLongLongMap) Test(org.junit.Test)

Example 28 with MutableLongLongMap

use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.

the class AbstractMutableLongLongMapTestCase method get.

@Override
@Test
public void get() {
    super.get();
    MutableLongLongMap map1 = this.classUnderTest();
    map1.put(0L, 1L);
    Assert.assertEquals(1L, map1.get(0L));
    map1.put(0L, 0L);
    Assert.assertEquals(0L, map1.get(0L));
    map1.put(5L, 5L);
    Assert.assertEquals(5L, map1.get(5L));
    map1.put(35L, 35L);
    Assert.assertEquals(35L, map1.get(35L));
}
Also used : MutableLongLongMap(org.eclipse.collections.api.map.primitive.MutableLongLongMap) Test(org.junit.Test)

Example 29 with MutableLongLongMap

use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.

the class AbstractMutableLongLongMapTestCase method freeze.

@Test
public void freeze() {
    MutableLongLongMap mutableLongLongMap = this.classUnderTest();
    LongSet frozenSet = mutableLongLongMap.keySet().freeze();
    LongSet frozenSetCopy = LongHashSet.newSetWith(mutableLongLongMap.keySet().toArray());
    Assert.assertEquals(frozenSet, frozenSetCopy);
    Assert.assertEquals(frozenSetCopy, mutableLongLongMap.keySet().freeze());
    for (int i = 0; i < 32; i++) {
        mutableLongLongMap.put((long) i, (long) i);
        Assert.assertEquals(frozenSet, frozenSetCopy);
    }
    LongSet frozenSetForRemove = mutableLongLongMap.keySet().freeze();
    LongSet frozenSetCopyForRemove = LongHashSet.newSetWith(mutableLongLongMap.keySet().toArray());
    Assert.assertEquals(frozenSetForRemove, frozenSetCopyForRemove);
    Assert.assertEquals(frozenSetCopyForRemove, mutableLongLongMap.keySet().freeze());
    for (int i = 0; i < 32; i++) {
        mutableLongLongMap.remove((long) i);
        Assert.assertEquals(frozenSetForRemove, frozenSetCopyForRemove);
    }
    MutableLongLongMap mutableLongLongMapForClear = this.classUnderTest();
    LongSet frozenSetForClear = mutableLongLongMapForClear.keySet().freeze();
    LongSet frozenSetCopyForClear = LongHashSet.newSetWith(mutableLongLongMapForClear.keySet().toArray());
    mutableLongLongMapForClear.clear();
    Assert.assertEquals(frozenSetForClear, frozenSetCopyForClear);
}
Also used : LongSet(org.eclipse.collections.api.set.primitive.LongSet) MutableLongLongMap(org.eclipse.collections.api.map.primitive.MutableLongLongMap) Test(org.junit.Test)

Example 30 with MutableLongLongMap

use of org.eclipse.collections.api.map.primitive.MutableLongLongMap in project mapdb by jankotek.

the class AbstractMutableLongLongMapTestCase method getIfAbsentPut.

@Test
public void getIfAbsentPut() {
    MutableLongLongMap map1 = this.getEmptyMap();
    Assert.assertEquals(50L, map1.getIfAbsentPut(0L, 50L));
    Assert.assertEquals(50L, map1.getIfAbsentPut(0L, 100L));
    Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 50L), map1);
    Assert.assertEquals(50L, map1.getIfAbsentPut(1L, 50L));
    Assert.assertEquals(50L, map1.getIfAbsentPut(1L, 100L));
    Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 50L, 1L, 50L), map1);
    MutableLongLongMap map2 = this.getEmptyMap();
    Assert.assertEquals(50L, map2.getIfAbsentPut(1L, 50L));
    Assert.assertEquals(50L, map2.getIfAbsentPut(1L, 100L));
    Assert.assertEquals(LongLongHashMap.newWithKeysValues(1L, 50L), map2);
    Assert.assertEquals(50L, map2.getIfAbsentPut(0L, 50L));
    Assert.assertEquals(50L, map2.getIfAbsentPut(0L, 100L));
    Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 50L, 1L, 50L), map2);
    MutableLongLongMap map3 = this.getEmptyMap();
    Assert.assertEquals(50L, map3.getIfAbsentPut(32L, 50L));
    Assert.assertEquals(50L, map3.getIfAbsentPut(32L, 100L));
    Assert.assertEquals(LongLongHashMap.newWithKeysValues(32L, 50L), map3);
    MutableLongLongMap map4 = this.getEmptyMap();
    Assert.assertEquals(50L, map4.getIfAbsentPut(33L, 50L));
    Assert.assertEquals(50L, map4.getIfAbsentPut(33L, 100L));
    Assert.assertEquals(LongLongHashMap.newWithKeysValues(33L, 50L), map4);
}
Also used : MutableLongLongMap(org.eclipse.collections.api.map.primitive.MutableLongLongMap) Test(org.junit.Test)

Aggregations

MutableLongLongMap (org.eclipse.collections.api.map.primitive.MutableLongLongMap)30 Test (org.junit.Test)30 MutableLongCollection (org.eclipse.collections.api.collection.primitive.MutableLongCollection)6 LongLongHashMap (org.eclipse.collections.impl.map.mutable.primitive.LongLongHashMap)6 LongToLongFunction (org.eclipse.collections.api.block.function.primitive.LongToLongFunction)2 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)2 LongFunction0 (org.eclipse.collections.api.block.function.primitive.LongFunction0)1 MutableLongIterator (org.eclipse.collections.api.iterator.MutableLongIterator)1 LongSet (org.eclipse.collections.api.set.primitive.LongSet)1