use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method detectIfNone_value.
@Test
public void detectIfNone_value() {
LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
long resultNotFound = map.detectIfNone(LongPredicates.greaterThan(5L), 5L);
Assert.assertEquals(5L, resultNotFound);
Assert.assertEquals(5L, this.getEmptyMap().detectIfNone(LongPredicates.equal(0L), 5L));
Assert.assertEquals(5L, this.newWithKeysValues(1L, 1L).detectIfNone(LongPredicates.equal(0L), 5L));
Assert.assertEquals(1L, this.newWithKeysValues(1L, 1L).detectIfNone(LongPredicates.equal(1L), 5L));
Assert.assertEquals(0L, map.detectIfNone(LongPredicates.equal(0L), 5L));
Assert.assertEquals(1L, map.detectIfNone(LongPredicates.equal(1L), 5L));
Assert.assertEquals(2L, map.detectIfNone(LongPredicates.equal(2L), 5L));
}
use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method forEachKey.
@Test
public void forEachKey() {
LongLongMap map0 = this.newWithKeysValues(0L, 1L, 3L, 4L);
long[] sum0 = new long[1];
map0.forEachKey(each -> sum0[0] += each);
Assert.assertEquals(3L, sum0[0]);
LongLongMap map1 = this.newWithKeysValues(1L, 2L, 3L, 4L);
long[] sum1 = new long[1];
map1.forEachKey(each -> sum1[0] += each);
Assert.assertEquals(4L, sum1[0]);
LongLongMap map01 = this.newWithKeysValues(0L, 1L, 1L, 2L);
long[] sum01 = new long[1];
map01.forEachKey(each -> sum01[0] += each);
Assert.assertEquals(1L, sum01[0]);
LongLongMap map = this.newWithKeysValues(3L, 4L, 4L, 5L);
long[] sum = new long[1];
map.forEachKey(each -> sum[0] += each);
Assert.assertEquals(7L, sum[0]);
LongLongMap map2 = this.getEmptyMap();
long[] sum2 = new long[1];
map2.forEachKey(each -> sum2[0] += each);
Assert.assertEquals(0L, sum2[0]);
LongLongMap map3 = this.newWithKeysValues(1L, 1L);
long[] sum3 = new long[1];
map3.forEachKey(each -> sum3[0] += each);
Assert.assertEquals(1L, sum3[0]);
}
use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method allSatisfy.
@Test
public void allSatisfy() {
LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
Assert.assertTrue(this.getEmptyMap().allSatisfy(LongPredicates.equal(0L)));
Assert.assertFalse(this.newWithKeysValues(1L, 1L).allSatisfy(LongPredicates.equal(0L)));
Assert.assertTrue(this.newWithKeysValues(1L, 1L).allSatisfy(LongPredicates.equal(1L)));
Assert.assertFalse(map.allSatisfy(LongPredicates.equal(0L)));
Assert.assertFalse(map.allSatisfy(LongPredicates.equal(1L)));
Assert.assertFalse(map.allSatisfy(LongPredicates.equal(2L)));
Assert.assertTrue(map.allSatisfy(LongPredicates.lessThan(5L)));
LongLongMap map1 = this.newWithKeysValues(2L, 2L, 3L, 3L);
Assert.assertFalse(map1.allSatisfy(LongPredicates.equal(0L)));
}
use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method toSortedList.
@Test
public void toSortedList() {
LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
Assert.assertEquals(LongArrayList.newListWith(0L, 1L, 2L, 3L), map.toSortedList());
Assert.assertEquals(LongArrayList.newListWith(), this.getEmptyMap().toSortedList());
Assert.assertEquals(LongArrayList.newListWith(1L), this.newWithKeysValues(1L, 1L).toSortedList());
}
use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method select_value.
@Test
public void select_value() {
LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
LongIterable actual1 = map.select(LongPredicates.greaterThan(1L));
Assert.assertEquals(LongBags.immutable.with(2L, 3L), actual1);
LongIterable actual2 = map.select(LongPredicates.lessThan(2L));
Assert.assertEquals(LongBags.immutable.with(0L, 1L), actual2);
}
Aggregations