use of org.eclipse.collections.api.bag.primitive.MutableIntBag in project eclipse-collections by eclipse.
the class AbstractMutableMap method collectInt.
@Override
public MutableIntBag collectInt(IntFunction<? super V> intFunction) {
MutableIntBag result = new IntHashBag();
this.forEach(new CollectIntProcedure<>(intFunction, result));
return result;
}
use of org.eclipse.collections.api.bag.primitive.MutableIntBag in project eclipse-collections by eclipse.
the class AbstractBag method collectInt.
@Override
public <R extends MutableIntCollection> R collectInt(IntFunction<? super T> intFunction, R target) {
if (target instanceof MutableIntBag) {
MutableIntBag targetBag = (MutableIntBag) target;
this.forEachWithOccurrences((each, occurrences) -> targetBag.addOccurrences(intFunction.intValueOf(each), occurrences));
} else {
this.forEachWithOccurrences((each, occurrences) -> {
int value = intFunction.intValueOf(each);
for (int i = 0; i < occurrences; i++) {
target.add(value);
}
});
}
return target;
}
use of org.eclipse.collections.api.bag.primitive.MutableIntBag 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.api.bag.primitive.MutableIntBag in project eclipse-collections by eclipse.
the class PrimitiveStreamsTest method toIntBag.
@Test
public void toIntBag() {
MutableIntBag bag = PrimitiveStreams.mIntBag(IntStream.rangeClosed(1, 10));
Assert.assertEquals(IntInterval.oneTo(10).toBag(), bag);
Assert.assertEquals(IntBags.immutable.ofAll(IntStream.rangeClosed(1, 10)), bag);
}
Aggregations