Search in sources :

Example 21 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet in project mapdb by jankotek.

the class AbstractLongLongMapTestCase method longIterator.

@Test
public void longIterator() {
    MutableLongSet expected = LongHashSet.newSetWith(0L, 31L, 32L);
    MutableLongSet actual = LongHashSet.newSetWith();
    LongIterator iterator = this.map.longIterator();
    Assert.assertTrue(iterator.hasNext());
    actual.add(iterator.next());
    Assert.assertTrue(iterator.hasNext());
    actual.add(iterator.next());
    Assert.assertTrue(iterator.hasNext());
    actual.add(iterator.next());
    Assert.assertFalse(iterator.hasNext());
    Assert.assertEquals(expected, actual);
    Verify.assertThrows(NoSuchElementException.class, iterator::next);
    Verify.assertThrows(NoSuchElementException.class, () -> this.getEmptyMap().longIterator().next());
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) LongIterator(org.eclipse.collections.api.iterator.LongIterator) Test(org.junit.Test)

Example 22 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet in project mapdb by jankotek.

the class AbstractLongSetTestCase method asLazy.

@Override
@Test
public void asLazy() {
    super.asLazy();
    MutableLongSet set = this.newWith(0L, 1L, 31L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(1));
    Assert.assertEquals(set.toSet(), set.asLazy().toSet());
    Verify.assertInstanceOf(LazyLongIterable.class, set.asLazy());
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) Test(org.junit.Test)

Example 23 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet in project mapdb by jankotek.

the class AbstractLongSetTestCase method injectInto.

@Override
@Test
public void injectInto() {
    super.injectInto();
    MutableLongSet set = this.newWith(0L, 2L, 31L);
    Long sum = set.injectInto(Long.valueOf(0L), (Long result, long value) -> Long.valueOf((long) (result + value)));
    Assert.assertEquals(Long.valueOf(33L), sum);
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) Test(org.junit.Test)

Example 24 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet in project mapdb by jankotek.

the class AbstractLongSetTestCase method testHashCode.

@Override
@Test
public void testHashCode() {
    super.testEquals();
    MutableLongSet set1 = this.newWith(1L, 31L, 32L);
    MutableLongSet set2 = this.newWith(32L, 31L, 1L);
    Assert.assertEquals(set1.hashCode(), set2.hashCode());
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) Test(org.junit.Test)

Example 25 with MutableLongSet

use of org.eclipse.collections.api.set.primitive.MutableLongSet in project mapdb by jankotek.

the class AbstractLongSetTestCase method count.

@Override
@Test
public void count() {
    super.count();
    MutableLongSet set = this.newWith(0L, 1L, 31L, AbstractLongSetTestCase.generateCollisions1().getFirst(), AbstractLongSetTestCase.generateCollisions1().get(1));
    Assert.assertEquals(4L, set.count(LongPredicates.greaterThan(0L)));
    Assert.assertEquals(3L, set.count(LongPredicates.lessThan(32L)));
    Assert.assertEquals(1L, set.count(LongPredicates.greaterThan(32L)));
}
Also used : MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) Test(org.junit.Test)

Aggregations

MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)26 Test (org.junit.Test)24 LongHashSet (org.eclipse.collections.impl.set.mutable.primitive.LongHashSet)5 LongIterator (org.eclipse.collections.api.iterator.LongIterator)3 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)2