Search in sources :

Example 1 with LongSet

use of org.eclipse.collections.api.set.primitive.LongSet 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)

Aggregations

MutableLongLongMap (org.eclipse.collections.api.map.primitive.MutableLongLongMap)1 LongSet (org.eclipse.collections.api.set.primitive.LongSet)1 Test (org.junit.Test)1