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());
}
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());
}
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();
}
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;
}
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);
}
Aggregations