Search in sources :

Example 1 with MutableShortBag

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();
}
Also used : MutableShortBag(org.eclipse.collections.api.bag.primitive.MutableShortBag) ShortHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag)

Example 2 with MutableShortBag

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;
}
Also used : MutableShortBag(org.eclipse.collections.api.bag.primitive.MutableShortBag) ShortHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag)

Example 3 with MutableShortBag

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;
}
Also used : MutableShortBag(org.eclipse.collections.api.bag.primitive.MutableShortBag)

Aggregations

MutableShortBag (org.eclipse.collections.api.bag.primitive.MutableShortBag)3 ShortHashBag (org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag)2