use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method collect.
@Test
public void collect() {
LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
LongToObjectFunction<Long> function = (parameter) -> parameter + 1;
Assert.assertEquals(Bags.immutable.with(1L, 2L, 3L, 4L), map.collect(function));
Assert.assertEquals(Bags.immutable.empty(), this.getEmptyMap().collect(function));
Assert.assertEquals(Bags.immutable.with(2L), this.newWithKeysValues(1L, 1L).collect(function));
}
use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method forEach.
@Test
public void forEach() {
LongLongMap map0 = this.newWithKeysValues(0L, 1L, 3L, 4L);
long[] sum0 = new long[1];
map0.forEach(each -> sum0[0] += each);
Assert.assertEquals(5L, sum0[0]);
LongLongMap map1 = this.newWithKeysValues(1L, 2L, 3L, 4L);
long[] sum1 = new long[1];
map1.forEach(each -> sum1[0] += each);
Assert.assertEquals(6L, sum1[0]);
LongLongMap map01 = this.newWithKeysValues(0L, 1L, 1L, 2L);
long[] sum01 = new long[1];
map01.forEach(each -> sum01[0] += each);
Assert.assertEquals(3L, sum01[0]);
LongLongMap map = this.newWithKeysValues(3L, 4L, 4L, 5L);
long[] sum = new long[1];
map.forEach(each -> sum[0] += each);
Assert.assertEquals(9L, sum[0]);
LongLongMap map2 = this.getEmptyMap();
long[] sum2 = new long[1];
map2.forEach(each -> sum2[0] += each);
Assert.assertEquals(0L, sum2[0]);
LongLongMap map3 = this.newWithKeysValues(1L, 2L);
long[] sum3 = new long[1];
map3.forEach(each -> sum3[0] += each);
Assert.assertEquals(2L, sum3[0]);
}
use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method median.
@Test
public void median() {
LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
Assert.assertEquals(1.5, map.median(), 0.0);
LongLongMap map2 = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L);
Assert.assertEquals(1.0, map2.median(), 0.0);
LongLongMap map3 = this.newWithKeysValues(1L, 1L);
Assert.assertEquals(1.0, map3.median(), 0.0);
}
use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method reject.
@Test
public void reject() {
LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
LongLongMap actual1 = map.reject((long key, long value) -> key == 1L || value == 3L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 0L, 2L, 2L), actual1);
LongLongMap actual2 = map.reject((long key, long value) -> key == 0L || value == 2L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(1L, 1L, 3L, 3L), actual2);
}
use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method minIfEmpty.
@Test
public void minIfEmpty() {
Assert.assertEquals(5L, this.getEmptyMap().minIfEmpty(5L));
Assert.assertEquals(0L, this.getEmptyMap().minIfEmpty(0L));
LongLongMap map = this.newWithKeysValues(1L, 1L, 0L, 0L, 9L, 9L, 7L, 7L);
Assert.assertEquals(0L, map.minIfEmpty(5L));
Assert.assertEquals(3L, this.newWithKeysValues(3L, 3L).maxIfEmpty(5L));
}
Aggregations