Search in sources :

Example 16 with LongLongMap

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

the class AbstractLongLongMapTestCase method testToString.

//    @Test
//    public void testHashCode()
//    {
//        Assert.assertEquals(
//                UnifiedMap.newWithKeysValues(0L, 0L, 1L, 1L, 32L, 32L).hashCode(),
//                this.newWithKeysValues(32L, 32L, 0L, 0L, 1L, 1L).hashCode());
//        Assert.assertEquals(
//                UnifiedMap.newWithKeysValues(50L, 0L, 60L, 1L, 70L, 33L).hashCode(),
//                this.newWithKeysValues(50L, 0L, 60L, 1L, 70L, 33L).hashCode());
//        Assert.assertEquals(UnifiedMap.newMap().hashCode(), this.getEmptyMap().hashCode());
//        Assert.assertEquals(UnifiedMap.newWithKeysValues(1L, 2L).hashCode(), this.newWithKeysValues(1L, 2L).hashCode());
//    }
@Test
public void testToString() {
    Assert.assertEquals("{}", this.getEmptyMap().toString());
    Assert.assertEquals("{0=0}", this.newWithKeysValues(0L, 0L).toString());
    Assert.assertEquals("{1=1}", this.newWithKeysValues(1L, 1L).toString());
    Assert.assertEquals("{5=5}", this.newWithKeysValues(5L, 5L).toString());
    LongLongMap map1 = this.newWithKeysValues(0L, 0L, 1L, 1L);
    Assert.assertTrue(map1.toString(), "{0=0, 1=1}".equals(map1.toString()) || "{1=1, 0=0}".equals(map1.toString()));
    LongLongMap map2 = this.newWithKeysValues(1L, 1L, 32L, 32L);
    Assert.assertTrue(map2.toString(), "{1=1, 32=32}".equals(map2.toString()) || "{32=32, 1=1}".equals(map2.toString()));
    LongLongMap map3 = this.newWithKeysValues(0L, 0L, 32L, 32L);
    Assert.assertTrue(map3.toString(), "{0=0, 32=32}".equals(map3.toString()) || "{32=32, 0=0}".equals(map3.toString()));
    LongLongMap map4 = this.newWithKeysValues(32L, 32L, 33L, 33L);
    Assert.assertTrue(map4.toString(), "{32=32, 33=33}".equals(map4.toString()) || "{33=33, 32=32}".equals(map4.toString()));
}
Also used : ImmutableLongLongMap(org.eclipse.collections.api.map.primitive.ImmutableLongLongMap) LongLongMap(org.eclipse.collections.api.map.primitive.LongLongMap) Test(org.junit.Test)

Example 17 with LongLongMap

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

the class AbstractLongLongMapTestCase method values.

@Test
public void values() {
    Verify.assertEmpty(this.getEmptyMap().values());
    LongLongMap map = this.newWithKeysValues(0L, 0L);
    Verify.assertSize(1, map.values());
    Assert.assertTrue(map.values().contains(0L));
    LongLongMap map1 = this.newWithKeysValues(0L, 0L, 31L, 31L, 32L, 32L);
    Verify.assertSize(3, map1.values());
    Assert.assertTrue(map1.values().contains(0L));
    Assert.assertTrue(map1.values().contains(31L));
    Assert.assertTrue(map1.values().contains(32L));
}
Also used : ImmutableLongLongMap(org.eclipse.collections.api.map.primitive.ImmutableLongLongMap) LongLongMap(org.eclipse.collections.api.map.primitive.LongLongMap) Test(org.junit.Test)

Example 18 with LongLongMap

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

the class AbstractLongLongMapTestCase method count.

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

Example 19 with LongLongMap

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

the class AbstractLongLongMapTestCase method anySatisfy.

@Test
public void anySatisfy() {
    LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
    Assert.assertFalse(this.getEmptyMap().anySatisfy(LongPredicates.equal(0L)));
    Assert.assertFalse(this.newWithKeysValues(1L, 1L).anySatisfy(LongPredicates.equal(0L)));
    Assert.assertTrue(this.newWithKeysValues(1L, 1L).anySatisfy(LongPredicates.equal(1L)));
    Assert.assertTrue(map.anySatisfy(LongPredicates.equal(0L)));
    Assert.assertTrue(map.anySatisfy(LongPredicates.equal(1L)));
    Assert.assertTrue(map.anySatisfy(LongPredicates.equal(2L)));
    Assert.assertFalse(map.anySatisfy(LongPredicates.greaterThan(5L)));
}
Also used : ImmutableLongLongMap(org.eclipse.collections.api.map.primitive.ImmutableLongLongMap) LongLongMap(org.eclipse.collections.api.map.primitive.LongLongMap) Test(org.junit.Test)

Example 20 with LongLongMap

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

the class AbstractLongLongMapTestCase method forEachValue.

@Test
public void forEachValue() {
    LongLongMap map0 = this.newWithKeysValues(0L, 1L, 3L, 4L);
    long[] sum0 = new long[1];
    map0.forEachValue(each -> sum0[0] += each);
    Assert.assertEquals(5L, sum0[0]);
    LongLongMap map1 = this.newWithKeysValues(1L, 2L, 3L, 4L);
    long[] sum1 = new long[1];
    map1.forEachValue(each -> sum1[0] += each);
    Assert.assertEquals(6L, sum1[0]);
    LongLongMap map01 = this.newWithKeysValues(0L, 1L, 1L, 2L);
    long[] sum01 = new long[1];
    map01.forEachValue(each -> sum01[0] += each);
    Assert.assertEquals(3L, sum01[0]);
    LongLongMap map = this.newWithKeysValues(3L, 4L, 4L, 5L);
    long[] sum = new long[1];
    map.forEachValue(each -> sum[0] += each);
    Assert.assertEquals(9L, sum[0]);
    LongLongMap map2 = this.getEmptyMap();
    long[] sum2 = new long[1];
    map2.forEachValue(each -> sum2[0] += each);
    Assert.assertEquals(0L, sum2[0]);
    LongLongMap map3 = this.newWithKeysValues(1L, 2L);
    long[] sum3 = new long[1];
    map3.forEachValue(each -> sum3[0] += each);
    Assert.assertEquals(2L, sum3[0]);
}
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