Search in sources :

Example 6 with LongHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag in project eclipse-collections by eclipse.

the class MapIterableTestCase method collectLongWithTarget.

@Test
public void collectLongWithTarget() {
    LongHashBag target = new LongHashBag();
    MapIterable<String, String> map = this.newMapWithKeysValues("One", "1", "Two", "2", "Three", "3");
    LongHashBag result = map.collectLong(Long::parseLong, target);
    Assert.assertSame("Target sent as parameter not returned", target, result);
    Assert.assertEquals(LongHashBag.newBagWith(1L, 2L, 3L), result.toBag());
}
Also used : LongHashBag(org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag) Test(org.junit.Test)

Example 7 with LongHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag in project mapdb by jankotek.

the class AbstractLongIterableTestCase method toBag.

@Test
public void toBag() {
    Assert.assertEquals(new LongHashBag(), this.newWith().toBag());
    Assert.assertEquals(LongHashBag.newBagWith(1L), this.newWith(1L).toBag());
    Assert.assertEquals(LongHashBag.newBagWith(1L, 2L, 3L), this.newWith(1L, 2L, 3L).toBag());
    Assert.assertEquals(LongHashBag.newBagWith(1L, 2L, 2L, 3L, 3L, 3L), this.newWith(1L, 2L, 2L, 3L, 3L, 3L).toBag());
    Assert.assertEquals(LongHashBag.newBagWith(0L, 1L, 31L, 32L), this.newWith(0L, 1L, 31L, 32L).toBag());
}
Also used : LongHashBag(org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag) Test(org.junit.Test)

Example 8 with LongHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag in project eclipse-collections by eclipse.

the class AbstractImmutableMap method collectLong.

@Override
public ImmutableLongBag collectLong(LongFunction<? super V> longFunction) {
    MutableLongBag result = new LongHashBag();
    this.forEach(new CollectLongProcedure<>(longFunction, result));
    return result.toImmutable();
}
Also used : MutableLongBag(org.eclipse.collections.api.bag.primitive.MutableLongBag) LongHashBag(org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag)

Example 9 with LongHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag in project eclipse-collections by eclipse.

the class AbstractMutableMap method collectLong.

@Override
public MutableLongBag collectLong(LongFunction<? super V> longFunction) {
    MutableLongBag result = new LongHashBag();
    this.forEach(new CollectLongProcedure<>(longFunction, result));
    return result;
}
Also used : MutableLongBag(org.eclipse.collections.api.bag.primitive.MutableLongBag) LongHashBag(org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag)

Example 10 with LongHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag in project eclipse-collections by eclipse.

the class MapIterateTest method collectLongWithTarget.

@Test
public void collectLongWithTarget() {
    LongHashBag target = new LongHashBag();
    LongHashBag result = MapIterate.collectLong(MapIterateTest.newLittleMap(), PrimitiveFunctions.unboxIntegerToLong(), target);
    Assert.assertEquals(LongHashBag.newBagWith(1L, 2L), result.toBag());
    Assert.assertSame("Target sent as parameter was not returned as result", target, result);
}
Also used : LongHashBag(org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag) Test(org.junit.Test)

Aggregations

LongHashBag (org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag)10 Test (org.junit.Test)8 MutableLongBag (org.eclipse.collections.api.bag.primitive.MutableLongBag)2 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Collectors (java.util.stream.Collectors)1 BooleanIterable (org.eclipse.collections.api.BooleanIterable)1 ByteIterable (org.eclipse.collections.api.ByteIterable)1 CharIterable (org.eclipse.collections.api.CharIterable)1 DoubleIterable (org.eclipse.collections.api.DoubleIterable)1 FloatIterable (org.eclipse.collections.api.FloatIterable)1 IntIterable (org.eclipse.collections.api.IntIterable)1 LongIterable (org.eclipse.collections.api.LongIterable)1 RichIterable (org.eclipse.collections.api.RichIterable)1 ShortIterable (org.eclipse.collections.api.ShortIterable)1