use of org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag in project eclipse-collections by eclipse.
the class ImmutableEmptySortedBagTest method collectInt_target.
@Override
@Test
public void collectInt_target() {
ImmutableSortedBag<Integer> bag = this.classUnderTest();
Assert.assertEquals(new IntArrayList(), bag.collectInt(PrimitiveFunctions.unboxIntegerToInt(), new IntArrayList()));
ImmutableSortedBag<Integer> bag2 = this.classUnderTest();
Assert.assertEquals(new IntHashBag(), bag2.collectInt(PrimitiveFunctions.unboxIntegerToInt(), new IntHashBag()));
}
use of org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag in project eclipse-collections by eclipse.
the class MapIterableTestCase method collectIntWithTarget.
@Test
public void collectIntWithTarget() {
IntHashBag target = new IntHashBag();
MapIterable<String, String> map = this.newMapWithKeysValues("One", "1", "Two", "2", "Three", "3");
IntHashBag result = map.collectInt(Integer::parseInt, target);
Assert.assertSame("Target sent as parameter not returned", target, result);
Assert.assertEquals(IntHashBag.newBagWith(1, 2, 3), result.toBag());
}
use of org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag in project eclipse-collections by eclipse.
the class AbstractImmutableMap method collectInt.
@Override
public ImmutableIntBag collectInt(IntFunction<? super V> intFunction) {
MutableIntBag result = new IntHashBag();
this.forEach(new CollectIntProcedure<>(intFunction, result));
return result.toImmutable();
}
use of org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag in project eclipse-collections by eclipse.
the class AbstractRichIterableTestCase method collectIntWithBagTarget.
@Test
public void collectIntWithBagTarget() {
IntHashBag target = new IntHashBag();
IntHashBag result = this.newWith(1, 2, 3, 4).collectInt(PrimitiveFunctions.unboxIntegerToInt(), target);
Assert.assertSame("Target list sent as parameter not returned", target, result);
Assert.assertEquals(IntHashBag.newBagWith(1, 2, 3, 4), result);
}
Aggregations