use of org.eclipse.collections.api.bag.primitive.MutableShortBag in project eclipse-collections by eclipse.
the class AbstractImmutableMap method collectShort.
@Override
public ImmutableShortBag collectShort(ShortFunction<? super V> shortFunction) {
MutableShortBag result = new ShortHashBag();
this.forEach(new CollectShortProcedure<>(shortFunction, result));
return result.toImmutable();
}
use of org.eclipse.collections.api.bag.primitive.MutableShortBag in project eclipse-collections by eclipse.
the class AbstractMutableMap method collectShort.
@Override
public MutableShortBag collectShort(ShortFunction<? super V> shortFunction) {
MutableShortBag result = new ShortHashBag();
this.forEach(new CollectShortProcedure<>(shortFunction, result));
return result;
}
use of org.eclipse.collections.api.bag.primitive.MutableShortBag in project eclipse-collections by eclipse.
the class AbstractBag method collectShort.
@Override
public <R extends MutableShortCollection> R collectShort(ShortFunction<? super T> shortFunction, R target) {
if (target instanceof MutableShortBag) {
MutableShortBag targetBag = (MutableShortBag) target;
this.forEachWithOccurrences((each, occurrences) -> targetBag.addOccurrences(shortFunction.shortValueOf(each), occurrences));
} else {
this.forEachWithOccurrences((each, occurrences) -> {
short value = shortFunction.shortValueOf(each);
for (int i = 0; i < occurrences; i++) {
target.add(value);
}
});
}
return target;
}
Aggregations