Search in sources :

Example 31 with LongIterable

use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.

the class AbstractLongLongMapTestCase method reject_value.

@Test
public void reject_value() {
    LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
    LongIterable actual1 = map.reject(LongPredicates.lessThan(2L));
    Assert.assertEquals(LongBags.immutable.with(2L, 3L), actual1);
    LongIterable actual2 = map.reject(LongPredicates.greaterThan(1L));
    Assert.assertEquals(LongBags.immutable.with(0L, 1L), actual2);
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) ImmutableLongLongMap(org.eclipse.collections.api.map.primitive.ImmutableLongLongMap) LongLongMap(org.eclipse.collections.api.map.primitive.LongLongMap) Test(org.junit.Test)

Example 32 with LongIterable

use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.

the class AbstractLongIterableTestCase method reject.

@Test
public void reject() {
    LongIterable iterable = this.classUnderTest();
    int size = iterable.size();
    Verify.assertSize(size <= 3 ? 0 : size - 3, iterable.reject(LongPredicates.lessThan(4L)));
    Verify.assertSize(size <= 2 ? 0 : size - 2, iterable.reject(LongPredicates.lessThan(3L)));
    LongIterable iterable1 = this.newWith(0L, 1L, 2L, 2L, 3L, 3L, 3L);
    Assert.assertEquals(this.newMutableCollectionWith(2L, 2L, 3L, 3L, 3L), iterable1.reject(LongPredicates.lessThan(2L)));
    Assert.assertEquals(this.newMutableCollectionWith(0L, 1L), iterable1.reject(LongPredicates.greaterThan(1L)));
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 33 with LongIterable

use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.

the class AbstractLongIterableTestCase method injectInto.

@Test
public void injectInto() {
    LongIterable iterable1 = this.newWith(0L, 2L, 31L);
    Long sum1 = iterable1.injectInto(Long.valueOf(0L), (Long result, long value) -> Long.valueOf((long) (result + value + 1)));
    Assert.assertEquals(Long.valueOf(36L), sum1);
    LongIterable iterable2 = this.newWith(1L, 2L, 31L);
    Long sum2 = iterable2.injectInto(Long.valueOf(0L), (Long result, long value) -> Long.valueOf((long) (result + value + 1)));
    Assert.assertEquals(Long.valueOf(37L), sum2);
    LongIterable iterable3 = this.newWith(0L, 1L, 2L, 31L);
    Long sum3 = iterable3.injectInto(Long.valueOf(0L), (Long result, long value) -> Long.valueOf((long) (result + value + 1)));
    Assert.assertEquals(Long.valueOf(38L), sum3);
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 34 with LongIterable

use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.

the class AbstractLongIterableTestCase method longIterator_throws_non_empty_collection.

@Test(expected = NoSuchElementException.class)
public void longIterator_throws_non_empty_collection() {
    LongIterable iterable = this.newWith(1L, 2L, 3L);
    LongIterator iterator = iterable.longIterator();
    while (iterator.hasNext()) {
        iterator.next();
    }
    iterator.next();
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) LongIterator(org.eclipse.collections.api.iterator.LongIterator) Test(org.junit.Test)

Example 35 with LongIterable

use of org.eclipse.collections.api.LongIterable in project mapdb by jankotek.

the class AbstractLongIterableTestCase method asLazy.

@Test
public void asLazy() {
    LongIterable iterable = this.classUnderTest();
    Assert.assertEquals(iterable.toBag(), iterable.asLazy().toBag());
    Verify.assertInstanceOf(LazyLongIterable.class, iterable.asLazy());
    LongIterable iterable1 = this.newWith(1L, 2L, 2L, 3L, 3L, 3L);
    Assert.assertEquals(iterable1.toBag(), iterable1.asLazy().toBag());
    Verify.assertInstanceOf(LazyLongIterable.class, iterable1.asLazy());
    LongIterable iterable2 = this.newWith(1L, 2L, 2L, 3L, 3L, 3L);
    Assert.assertEquals(iterable2.toBag(), iterable2.asLazy().toBag());
    Verify.assertInstanceOf(LazyLongIterable.class, iterable2.asLazy());
    LongIterable iterable3 = this.newWith();
    Assert.assertEquals(iterable3.toBag(), iterable3.asLazy().toBag());
    Verify.assertInstanceOf(LazyLongIterable.class, iterable3.asLazy());
    LongIterable iterable4 = this.newWith(1L);
    Assert.assertEquals(iterable4.toBag(), iterable4.asLazy().toBag());
    Verify.assertInstanceOf(LazyLongIterable.class, iterable4.asLazy());
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Aggregations

LongIterable (org.eclipse.collections.api.LongIterable)60 Test (org.junit.Test)54 LazyLongIterable (org.eclipse.collections.api.LazyLongIterable)46 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)13 LongIterator (org.eclipse.collections.api.iterator.LongIterator)10 Arrays (java.util.Arrays)8 NoSuchElementException (java.util.NoSuchElementException)8 RichIterable (org.eclipse.collections.api.RichIterable)8 LongToObjectFunction (org.eclipse.collections.api.block.function.primitive.LongToObjectFunction)8 LongHashBag (org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag)8 LongPredicates (org.eclipse.collections.impl.block.factory.primitive.LongPredicates)8 LongHashSet (org.eclipse.collections.impl.set.mutable.primitive.LongHashSet)8 Verify (org.eclipse.collections.impl.test.Verify)8 Assert (org.junit.Assert)8 ImmutableLongLongMap (org.eclipse.collections.api.map.primitive.ImmutableLongLongMap)2 LongLongMap (org.eclipse.collections.api.map.primitive.LongLongMap)2 MutableLongCollection (org.eclipse.collections.api.collection.primitive.MutableLongCollection)1 IndexMap (org.neo4j.kernel.impl.api.index.IndexMap)1