@Override
public <R extends MutableShortCollection> R collectShort(final ShortFunction<? super T> shortFunction, final R target)
{
if (target instanceof MutableShortBag)
{
final MutableShortBag targetBag = (MutableShortBag) target;
this.forEachWithOccurrences(new ObjectIntProcedure<T>()
{
public void value(T each, int occurrences)
{
targetBag.addOccurrences(shortFunction.shortValueOf(each), occurrences);
}
});
}
else
{