use of org.eclipse.collections.api.bag.primitive.MutableCharBag in project eclipse-collections by eclipse.
the class AbstractMutableMap method collectChar.
@Override
public MutableCharBag collectChar(CharFunction<? super V> charFunction) {
MutableCharBag result = new CharHashBag();
this.forEach(new CollectCharProcedure<>(charFunction, result));
return result;
}
use of org.eclipse.collections.api.bag.primitive.MutableCharBag in project eclipse-collections by eclipse.
the class AbstractBag method collectChar.
@Override
public <R extends MutableCharCollection> R collectChar(CharFunction<? super T> charFunction, R target) {
if (target instanceof MutableCharBag) {
MutableCharBag targetBag = (MutableCharBag) target;
this.forEachWithOccurrences((each, occurrences) -> targetBag.addOccurrences(charFunction.charValueOf(each), occurrences));
} else {
this.forEachWithOccurrences((each, occurrences) -> {
char value = charFunction.charValueOf(each);
for (int i = 0; i < occurrences; i++) {
target.add(value);
}
});
}
return target;
}
use of org.eclipse.collections.api.bag.primitive.MutableCharBag in project eclipse-collections by eclipse.
the class AbstractImmutableMap method collectChar.
@Override
public ImmutableCharBag collectChar(CharFunction<? super V> charFunction) {
MutableCharBag result = new CharHashBag();
this.forEach(new CollectCharProcedure<>(charFunction, result));
return result.toImmutable();
}
use of org.eclipse.collections.api.bag.primitive.MutableCharBag in project eclipse-collections by eclipse.
the class CharAdapterTest method toBag.
@Override
public void toBag() {
super.toBag();
MutableCharBag expected = CharBags.mutable.empty();
expected.addOccurrences('a', 3);
expected.addOccurrences('b', 3);
expected.addOccurrences('c', 3);
Assert.assertEquals(expected, CharAdapter.adapt("aaabbbccc").toBag());
}
Aggregations