Search in sources :

Example 1 with LongLongMap

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

the class AbstractLongLongMapTestCase method makeString.

@Test
public void makeString() {
    Assert.assertEquals("", this.getEmptyMap().makeString());
    Assert.assertEquals("", this.getEmptyMap().makeString(", "));
    Assert.assertEquals("[]", this.getEmptyMap().makeString("[", "/", "]"));
    Assert.assertEquals("0", this.newWithKeysValues(0L, 0L).makeString());
    Assert.assertEquals("0", this.newWithKeysValues(0L, 0L).makeString(", "));
    Assert.assertEquals("[0]", this.newWithKeysValues(0L, 0L).makeString("[", "/", "]"));
    Assert.assertEquals("1", this.newWithKeysValues(1L, 1L).makeString());
    Assert.assertEquals("5", this.newWithKeysValues(5L, 5L).makeString());
    LongLongMap map1 = this.newWithKeysValues(0L, 0L, 1L, 1L);
    Assert.assertTrue(map1.makeString(), "0, 1".equals(map1.makeString()) || "1, 0".equals(map1.makeString()));
    LongLongMap map2 = this.newWithKeysValues(1L, 1L, 32L, 32L);
    Assert.assertTrue(map2.makeString("[", "/", "]"), "[1/32]".equals(map2.makeString("[", "/", "]")) || "[32/1]".equals(map2.makeString("[", "/", "]")));
    LongLongMap map3 = this.newWithKeysValues(0L, 0L, 32L, 32L);
    Assert.assertTrue(map3.makeString("~"), "0~32".equals(map3.makeString("~")) || "32~0".equals(map3.makeString("~")));
    LongLongMap map4 = this.newWithKeysValues(32L, 32L, 33L, 33L);
    Assert.assertTrue(map4.makeString("[", ", ", "]"), "[32, 33]".equals(map4.makeString("[", ", ", "]")) || "[33, 32]".equals(map4.makeString("[", ", ", "]")));
}
Also used : ImmutableLongLongMap(org.eclipse.collections.api.map.primitive.ImmutableLongLongMap) LongLongMap(org.eclipse.collections.api.map.primitive.LongLongMap) Test(org.junit.Test)

Example 2 with LongLongMap

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

the class AbstractLongLongMapTestCase method testEquals.

@Test
public void testEquals() {
    LongLongMap map1 = this.newWithKeysValues(0L, 0L, 1L, 1L, 32L, 32L);
    LongLongMap map2 = this.newWithKeysValues(32L, 32L, 0L, 0L, 1L, 1L);
    LongLongMap map3 = this.newWithKeysValues(0L, 0L, 1L, 2L, 32L, 32L);
    LongLongMap map4 = this.newWithKeysValues(0L, 1L, 1L, 1L, 32L, 32L);
    LongLongMap map5 = this.newWithKeysValues(0L, 0L, 1L, 1L, 32L, 33L);
    LongLongMap map6 = this.newWithKeysValues(50L, 0L, 60L, 1L, 70L, 33L);
    LongLongMap map7 = this.newWithKeysValues(50L, 0L, 60L, 1L);
    LongLongMap map8 = this.newWithKeysValues(0L, 0L, 1L, 1L);
    LongLongMap map9 = this.newWithKeysValues(0L, 0L);
    Verify.assertEqualsAndHashCode(map1, map2);
    //        Verify.assertPostSerializedEqualsAndHashCode(map1);
    //        Verify.assertPostSerializedEqualsAndHashCode(map6);
    //        Verify.assertPostSerializedEqualsAndHashCode(map8);
    //        Verify.assertPostSerializedEqualsAndHashCode(this.getEmptyMap());
    Assert.assertNotEquals(map1, map3);
    Assert.assertNotEquals(this.getEmptyMap(), map3);
    Assert.assertNotEquals(map9, this.getEmptyMap());
    Assert.assertNotEquals(this.getEmptyMap(), map9);
    Assert.assertNotEquals(LongArrayList.newListWith(0L), map9);
    Assert.assertNotEquals(map1, map4);
    Assert.assertNotEquals(map1, map5);
    Assert.assertNotEquals(map7, map6);
    Assert.assertNotEquals(map7, map8);
    Assert.assertEquals(map1, LongLongMaps.mutable.ofAll(map1));
    Assert.assertEquals(map1, LongLongMaps.immutable.ofAll(map1));
}
Also used : ImmutableLongLongMap(org.eclipse.collections.api.map.primitive.ImmutableLongLongMap) LongLongMap(org.eclipse.collections.api.map.primitive.LongLongMap) Test(org.junit.Test)

Example 3 with LongLongMap

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

the class AbstractLongLongMapTestCase method toSet.

@Test
public void toSet() {
    LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
    Assert.assertEquals(LongHashSet.newSetWith(0L, 1L, 2L, 3L), map.toSet());
    Assert.assertEquals(LongHashSet.newSetWith(), this.getEmptyMap().toSet());
    Assert.assertEquals(LongHashSet.newSetWith(1L), this.newWithKeysValues(1L, 1L).toSet());
}
Also used : ImmutableLongLongMap(org.eclipse.collections.api.map.primitive.ImmutableLongLongMap) LongLongMap(org.eclipse.collections.api.map.primitive.LongLongMap) Test(org.junit.Test)

Example 4 with LongLongMap

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

the class AbstractLongLongMapTestCase method forEachKeyValue.

@Test
public void forEachKeyValue() {
    LongLongMap map0 = this.newWithKeysValues(0L, 1L, 3L, 4L);
    long[] sumKey0 = new long[1];
    long[] sumValue0 = new long[1];
    map0.forEachKeyValue((long eachKey, long eachValue) -> {
        sumKey0[0] += eachKey;
        sumValue0[0] += eachValue;
    });
    Assert.assertEquals(3L, sumKey0[0]);
    Assert.assertEquals(5L, sumValue0[0]);
    LongLongMap map1 = this.newWithKeysValues(1L, 2L, 3L, 4L);
    long[] sumKey1 = new long[1];
    long[] sumValue1 = new long[1];
    map1.forEachKeyValue((long eachKey, long eachValue) -> {
        sumKey1[0] += eachKey;
        sumValue1[0] += eachValue;
    });
    Assert.assertEquals(4L, sumKey1[0]);
    Assert.assertEquals(6L, sumValue1[0]);
    LongLongMap map01 = this.newWithKeysValues(0L, 1L, 1L, 2L);
    long[] sumKey01 = new long[1];
    long[] sumValue01 = new long[1];
    map01.forEachKeyValue((long eachKey, long eachValue) -> {
        sumKey01[0] += eachKey;
        sumValue01[0] += eachValue;
    });
    Assert.assertEquals(1L, sumKey01[0]);
    Assert.assertEquals(3L, sumValue01[0]);
    LongLongMap map = this.newWithKeysValues(3L, 4L, 4L, 5L);
    long[] sumKey = new long[1];
    long[] sumValue = new long[1];
    map.forEachKeyValue((long eachKey, long eachValue) -> {
        sumKey[0] += eachKey;
        sumValue[0] += eachValue;
    });
    Assert.assertEquals(7L, sumKey[0]);
    Assert.assertEquals(9L, sumValue[0]);
    LongLongMap map2 = this.getEmptyMap();
    long[] sumKey2 = new long[1];
    long[] sumValue2 = new long[1];
    map2.forEachKeyValue((long eachKey, long eachValue) -> {
        sumKey2[0] += eachKey;
        sumValue2[0] += eachValue;
    });
    Assert.assertEquals(0L, sumKey2[0]);
    Assert.assertEquals(0L, sumValue2[0]);
    LongLongMap map3 = this.newWithKeysValues(3L, 5L);
    long[] sumKey3 = new long[1];
    long[] sumValue3 = new long[1];
    map3.forEachKeyValue((long eachKey, long eachValue) -> {
        sumKey3[0] += eachKey;
        sumValue3[0] += eachValue;
    });
    Assert.assertEquals(3L, sumKey3[0]);
    Assert.assertEquals(5L, sumValue3[0]);
}
Also used : ImmutableLongLongMap(org.eclipse.collections.api.map.primitive.ImmutableLongLongMap) LongLongMap(org.eclipse.collections.api.map.primitive.LongLongMap) Test(org.junit.Test)

Example 5 with LongLongMap

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

the class AbstractLongLongMapTestCase method min.

@Test
public void min() {
    LongLongMap map = this.newWithKeysValues(1L, 1L, 2L, 2L, 3L, 3L, 0L, 0L);
    Assert.assertEquals(0L, map.min());
    Assert.assertEquals(3L, this.newWithKeysValues(3L, 3L).min());
}
Also used : ImmutableLongLongMap(org.eclipse.collections.api.map.primitive.ImmutableLongLongMap) LongLongMap(org.eclipse.collections.api.map.primitive.LongLongMap) Test(org.junit.Test)

Aggregations

ImmutableLongLongMap (org.eclipse.collections.api.map.primitive.ImmutableLongLongMap)30 LongLongMap (org.eclipse.collections.api.map.primitive.LongLongMap)30 Test (org.junit.Test)30 LazyLongIterable (org.eclipse.collections.api.LazyLongIterable)3 LongIterable (org.eclipse.collections.api.LongIterable)3 Arrays (java.util.Arrays)1 NoSuchElementException (java.util.NoSuchElementException)1 MutableBag (org.eclipse.collections.api.bag.MutableBag)1 LongToObjectFunction (org.eclipse.collections.api.block.function.primitive.LongToObjectFunction)1 LongIterator (org.eclipse.collections.api.iterator.LongIterator)1 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)1 LongLongPair (org.eclipse.collections.api.tuple.primitive.LongLongPair)1 LongHashBag (org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag)1 LongPredicates (org.eclipse.collections.impl.block.factory.primitive.LongPredicates)1 Bags (org.eclipse.collections.impl.factory.Bags)1 LongBags (org.eclipse.collections.impl.factory.primitive.LongBags)1 LongLongMaps (org.eclipse.collections.impl.factory.primitive.LongLongMaps)1 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)1 LongLongHashMap (org.eclipse.collections.impl.map.mutable.primitive.LongLongHashMap)1 LongHashSet (org.eclipse.collections.impl.set.mutable.primitive.LongHashSet)1