use of org.eclipse.collections.impl.set.mutable.primitive.CharHashSet in project eclipse-collections by eclipse.
the class CharAdapter method distinct.
@Override
public CharAdapter distinct() {
StringBuilder builder = new StringBuilder();
CharHashSet seenSoFar = new CharHashSet();
int size = this.size();
for (int i = 0; i < size; i++) {
char each = this.get(i);
if (seenSoFar.add(each)) {
builder.append(each);
}
}
return new CharAdapter(builder.toString());
}
use of org.eclipse.collections.impl.set.mutable.primitive.CharHashSet in project eclipse-collections by eclipse.
the class AbstractMutableSet method collectChar.
@Override
public MutableCharSet collectChar(CharFunction<? super T> charFunction) {
MutableCharSet result = new CharHashSet(this.size());
this.forEach(new CollectCharProcedure<>(charFunction, result));
return result;
}
use of org.eclipse.collections.impl.set.mutable.primitive.CharHashSet in project eclipse-collections by eclipse.
the class SetAdapter method collectChar.
@Override
public MutableCharSet collectChar(CharFunction<? super T> charFunction) {
CharHashSet result = new CharHashSet(this.size());
this.forEach(new CollectCharProcedure<>(charFunction, result));
return result;
}
use of org.eclipse.collections.impl.set.mutable.primitive.CharHashSet in project eclipse-collections by eclipse.
the class StackIterableTestCase method collectCharWithTarget.
@Override
@Test
public void collectCharWithTarget() {
CharHashSet target = new CharHashSet();
StackIterable<Integer> stack = this.newStackFromTopToBottom(1, 2, 3);
CharHashSet result = stack.collectChar(PrimitiveFunctions.unboxIntegerToChar(), target);
Assert.assertEquals(CharHashSet.newSetWith((char) 1, (char) 2, (char) 3), result);
Assert.assertSame("Target sent as parameter not returned", target, result);
}
use of org.eclipse.collections.impl.set.mutable.primitive.CharHashSet in project eclipse-collections by eclipse.
the class AbstractImmutableSet method collectChar.
@Override
public ImmutableCharSet collectChar(CharFunction<? super T> charFunction) {
MutableCharSet result = new CharHashSet(this.size());
this.forEach(new CollectCharProcedure<>(charFunction, result));
return result.toImmutable();
}
Aggregations