Search in sources :

Example 1 with MutableByteBag

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

the class AbstractMutableMap method collectByte.

@Override
public MutableByteBag collectByte(ByteFunction<? super V> byteFunction) {
    MutableByteBag result = new ByteHashBag();
    this.forEach(new CollectByteProcedure<>(byteFunction, result));
    return result;
}
Also used : MutableByteBag(org.eclipse.collections.api.bag.primitive.MutableByteBag) ByteHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag)

Example 2 with MutableByteBag

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

the class AbstractImmutableMap method collectByte.

@Override
public ImmutableByteBag collectByte(ByteFunction<? super V> byteFunction) {
    MutableByteBag result = new ByteHashBag();
    this.forEach(new CollectByteProcedure<>(byteFunction, result));
    return result.toImmutable();
}
Also used : MutableByteBag(org.eclipse.collections.api.bag.primitive.MutableByteBag) ByteHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag)

Example 3 with MutableByteBag

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

the class AbstractBag method collectByte.

@Override
public <R extends MutableByteCollection> R collectByte(ByteFunction<? super T> byteFunction, R target) {
    if (target instanceof MutableByteBag) {
        MutableByteBag targetBag = (MutableByteBag) target;
        this.forEachWithOccurrences((each, occurrences) -> targetBag.addOccurrences(byteFunction.byteValueOf(each), occurrences));
    } else {
        this.forEachWithOccurrences((each, occurrences) -> {
            byte value = byteFunction.byteValueOf(each);
            for (int i = 0; i < occurrences; i++) {
                target.add(value);
            }
        });
    }
    return target;
}
Also used : MutableByteBag(org.eclipse.collections.api.bag.primitive.MutableByteBag)

Aggregations

MutableByteBag (org.eclipse.collections.api.bag.primitive.MutableByteBag)3 ByteHashBag (org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag)2