Search in sources :

Example 1 with LongToObjectFunction

use of org.eclipse.collections.api.block.function.primitive.LongToObjectFunction in project mapdb by jankotek.

the class AbstractLongIterableTestCase method collect.

@Test
public void collect() {
    LongToObjectFunction<Long> function = parameter -> parameter - 1;
    Assert.assertEquals(this.newObjectCollectionWith(0L, 1L, 2L), this.newWith(1L, 2L, 3L).collect(function));
    LongIterable iterable = this.newWith(1L, 2L, 2L, 3L, 3L, 3L);
    Assert.assertEquals(this.newObjectCollectionWith(0L, 1L, 1L, 2L, 2L, 2L), iterable.collect(function));
    Assert.assertEquals(this.newObjectCollectionWith(), this.newWith().collect(function));
    Assert.assertEquals(this.newObjectCollectionWith(2L), this.newWith(3L).collect(function));
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) Arrays(java.util.Arrays) Test(org.junit.Test) Verify(org.eclipse.collections.impl.test.Verify) LongHashBag(org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag) LongIterator(org.eclipse.collections.api.iterator.LongIterator) RichIterable(org.eclipse.collections.api.RichIterable) LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) LongIterable(org.eclipse.collections.api.LongIterable) LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) LongToObjectFunction(org.eclipse.collections.api.block.function.primitive.LongToObjectFunction) LongPredicates(org.eclipse.collections.impl.block.factory.primitive.LongPredicates) Assert(org.junit.Assert) NoSuchElementException(java.util.NoSuchElementException) LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) LongIterable(org.eclipse.collections.api.LongIterable) Test(org.junit.Test)

Example 2 with LongToObjectFunction

use of org.eclipse.collections.api.block.function.primitive.LongToObjectFunction 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));
}
Also used : LazyLongIterable(org.eclipse.collections.api.LazyLongIterable) ImmutableLongLongMap(org.eclipse.collections.api.map.primitive.ImmutableLongLongMap) Arrays(java.util.Arrays) Bags(org.eclipse.collections.impl.factory.Bags) Test(org.junit.Test) LongBags(org.eclipse.collections.impl.factory.primitive.LongBags) Verify(org.eclipse.collections.impl.test.Verify) MutableBag(org.eclipse.collections.api.bag.MutableBag) LongHashBag(org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag) MutableLongSet(org.eclipse.collections.api.set.primitive.MutableLongSet) LongIterator(org.eclipse.collections.api.iterator.LongIterator) LongLongMaps(org.eclipse.collections.impl.factory.primitive.LongLongMaps) LongHashSet(org.eclipse.collections.impl.set.mutable.primitive.LongHashSet) LongLongHashMap(org.eclipse.collections.impl.map.mutable.primitive.LongLongHashMap) LongIterable(org.eclipse.collections.api.LongIterable) PrimitiveTuples(org.eclipse.collections.impl.tuple.primitive.PrimitiveTuples) LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) LongToObjectFunction(org.eclipse.collections.api.block.function.primitive.LongToObjectFunction) LongPredicates(org.eclipse.collections.impl.block.factory.primitive.LongPredicates) Assert(org.junit.Assert) NoSuchElementException(java.util.NoSuchElementException) LongLongMap(org.eclipse.collections.api.map.primitive.LongLongMap) LongLongPair(org.eclipse.collections.api.tuple.primitive.LongLongPair) ImmutableLongLongMap(org.eclipse.collections.api.map.primitive.ImmutableLongLongMap) LongLongMap(org.eclipse.collections.api.map.primitive.LongLongMap) Test(org.junit.Test)

Aggregations

Arrays (java.util.Arrays)2 NoSuchElementException (java.util.NoSuchElementException)2 LazyLongIterable (org.eclipse.collections.api.LazyLongIterable)2 LongIterable (org.eclipse.collections.api.LongIterable)2 LongToObjectFunction (org.eclipse.collections.api.block.function.primitive.LongToObjectFunction)2 LongIterator (org.eclipse.collections.api.iterator.LongIterator)2 LongHashBag (org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag)2 LongPredicates (org.eclipse.collections.impl.block.factory.primitive.LongPredicates)2 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)2 LongHashSet (org.eclipse.collections.impl.set.mutable.primitive.LongHashSet)2 Verify (org.eclipse.collections.impl.test.Verify)2 Assert (org.junit.Assert)2 Test (org.junit.Test)2 RichIterable (org.eclipse.collections.api.RichIterable)1 MutableBag (org.eclipse.collections.api.bag.MutableBag)1 ImmutableLongLongMap (org.eclipse.collections.api.map.primitive.ImmutableLongLongMap)1 LongLongMap (org.eclipse.collections.api.map.primitive.LongLongMap)1 MutableLongSet (org.eclipse.collections.api.set.primitive.MutableLongSet)1 LongLongPair (org.eclipse.collections.api.tuple.primitive.LongLongPair)1 Bags (org.eclipse.collections.impl.factory.Bags)1