use of org.eclipse.collections.api.set.primitive.MutableLongSet in project neo4j by neo4j.
the class RelationshipTransactionStateTestBase method assertRelationships.
private void assertRelationships(NodeCursor node, RelationshipTraversalCursor traversal, RelationshipSelection selection, long... relationships) {
node.relationships(traversal, selection);
MutableLongSet set = LongHashSet.newSetWith(relationships);
for (long relationship : relationships) {
assertTrue(traversal.next());
assertTrue(set.contains(traversal.relationshipReference()));
set.remove(traversal.relationshipReference());
}
assertTrue(set.isEmpty());
assertFalse(traversal.next());
}
use of org.eclipse.collections.api.set.primitive.MutableLongSet in project neo4j by neo4j.
the class FreeListIdProviderTest method shouldVisitUnacquiredIds.
@Test
void shouldVisitUnacquiredIds() throws Exception {
// GIVEN a couple of released ids
MutableLongSet expected = new LongHashSet();
for (int i = 0; i < 100; i++) {
expected.add(freelist.acquireNewId(GENERATION_ONE, GENERATION_TWO, NULL));
}
expected.forEach(id -> {
try {
freelist.releaseId(GENERATION_ONE, GENERATION_TWO, id, NULL);
} catch (IOException e) {
throw new RuntimeException(e);
}
});
// and only a few acquired
for (int i = 0; i < 10; i++) {
long acquiredId = freelist.acquireNewId(GENERATION_TWO, GENERATION_THREE, NULL);
assertTrue(expected.remove(acquiredId));
}
// WHEN/THEN
freelist.visitFreelist(new IdProvider.IdProviderVisitor.Adaptor() {
@Override
public void freelistEntry(long pageId, long generation, int pos) {
assertTrue(expected.remove(pageId));
}
}, NULL);
assertTrue(expected.isEmpty());
}
use of org.eclipse.collections.api.set.primitive.MutableLongSet in project mapdb by jankotek.
the class LongLongHashMapKeySetTest method testEquals.
@Override
public void testEquals() {
MutableLongSet set1 = this.newWith(1L, 31L, 32L);
MutableLongSet set2 = this.newWith(32L, 31L, 1L);
MutableLongSet set3 = this.newWith(32L, 32L, 31L, 1L);
MutableLongSet set4 = this.newWith(32L, 32L, 31L, 1L, 1L);
MutableLongSet set5 = this.newWith(32L, 1L);
Verify.assertEqualsAndHashCode(set1, set2);
Verify.assertEqualsAndHashCode(set1, set3);
Verify.assertEqualsAndHashCode(set1, set4);
Verify.assertEqualsAndHashCode(set2, set3);
Verify.assertEqualsAndHashCode(set2, set4);
Assert.assertNotEquals(set1, set5);
}
use of org.eclipse.collections.api.set.primitive.MutableLongSet in project mapdb by jankotek.
the class AbstractLongSetTestCase method addAllIterable.
@Override
@Test
public void addAllIterable() {
super.addAllIterable();
MutableLongSet set = this.newWith(0L, 1L, 31L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(1));
Assert.assertFalse(set.addAll(new LongArrayList()));
Assert.assertFalse(set.addAll(LongArrayList.newListWith(31L, AbstractLongSetTestCase.generateCollisions1().get(0), AbstractLongSetTestCase.generateCollisions1().get(1))));
Assert.assertEquals(LongHashSet.newSetWith(0L, 1L, 31L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(1)), set);
Assert.assertTrue(set.addAll(LongHashSet.newSetWith(0L, 1L, 2L, 30L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(4))));
Assert.assertEquals(LongHashSet.newSetWith(0L, 1L, 2L, 30L, 31L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(1), AbstractLongSetTestCase.generateCollisions1().get(4)), set);
Assert.assertTrue(set.addAll(LongHashSet.newSetWith(5L)));
Assert.assertEquals(LongHashSet.newSetWith(0L, 1L, 2L, 5L, 30L, 31L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(1), AbstractLongSetTestCase.generateCollisions1().get(4)), set);
Assert.assertTrue(set.addAll(LongHashSet.newSetWith(AbstractLongSetTestCase.generateCollisions1().get(5))));
Assert.assertEquals(LongHashSet.newSetWith(0L, 1L, 2L, 5L, 30L, 31L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(1), AbstractLongSetTestCase.generateCollisions1().get(4), AbstractLongSetTestCase.generateCollisions1().get(5)), set);
LongHashSet set1 = new LongHashSet();
Assert.assertTrue(set1.addAll(2L, 35L));
Assert.assertEquals(LongHashSet.newSetWith(2L, 35L), set1);
}
use of org.eclipse.collections.api.set.primitive.MutableLongSet in project mapdb by jankotek.
the class AbstractLongSetTestCase method reject.
@Override
@Test
public void reject() {
super.reject();
MutableLongSet set = this.newWith(0L, 1L, 31L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(1));
Verify.assertSize(1, set.reject(LongPredicates.greaterThan(0L)));
Verify.assertSize(2, set.reject(LongPredicates.lessThan(32L)));
}
Aggregations