Search in sources :

Example 1 with MutableFloatBag

use of org.eclipse.collections.api.bag.primitive.MutableFloatBag in project eclipse-collections by eclipse.

the class AbstractImmutableMap method collectFloat.

@Override
public ImmutableFloatBag collectFloat(FloatFunction<? super V> floatFunction) {
    MutableFloatBag result = new FloatHashBag();
    this.forEach(new CollectFloatProcedure<>(floatFunction, result));
    return result.toImmutable();
}
Also used : FloatHashBag(org.eclipse.collections.impl.bag.mutable.primitive.FloatHashBag) MutableFloatBag(org.eclipse.collections.api.bag.primitive.MutableFloatBag)

Example 2 with MutableFloatBag

use of org.eclipse.collections.api.bag.primitive.MutableFloatBag in project eclipse-collections by eclipse.

the class AbstractMutableMap method collectFloat.

@Override
public MutableFloatBag collectFloat(FloatFunction<? super V> floatFunction) {
    MutableFloatBag result = new FloatHashBag();
    this.forEach(new CollectFloatProcedure<>(floatFunction, result));
    return result;
}
Also used : FloatHashBag(org.eclipse.collections.impl.bag.mutable.primitive.FloatHashBag) MutableFloatBag(org.eclipse.collections.api.bag.primitive.MutableFloatBag)

Example 3 with MutableFloatBag

use of org.eclipse.collections.api.bag.primitive.MutableFloatBag in project eclipse-collections by eclipse.

the class AbstractBag method collectFloat.

@Override
public <R extends MutableFloatCollection> R collectFloat(FloatFunction<? super T> floatFunction, R target) {
    if (target instanceof MutableFloatBag) {
        MutableFloatBag targetBag = (MutableFloatBag) target;
        this.forEachWithOccurrences((each, occurrences) -> targetBag.addOccurrences(floatFunction.floatValueOf(each), occurrences));
    } else {
        this.forEachWithOccurrences((each, occurrences) -> {
            float value = floatFunction.floatValueOf(each);
            for (int i = 0; i < occurrences; i++) {
                target.add(value);
            }
        });
    }
    return target;
}
Also used : MutableFloatBag(org.eclipse.collections.api.bag.primitive.MutableFloatBag)

Aggregations

MutableFloatBag (org.eclipse.collections.api.bag.primitive.MutableFloatBag)3 FloatHashBag (org.eclipse.collections.impl.bag.mutable.primitive.FloatHashBag)2