Search in sources :

Example 1 with CharHashSet

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());
}
Also used : CharHashSet(org.eclipse.collections.impl.set.mutable.primitive.CharHashSet)

Example 2 with CharHashSet

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;
}
Also used : MutableCharSet(org.eclipse.collections.api.set.primitive.MutableCharSet) CharHashSet(org.eclipse.collections.impl.set.mutable.primitive.CharHashSet)

Example 3 with CharHashSet

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;
}
Also used : CharHashSet(org.eclipse.collections.impl.set.mutable.primitive.CharHashSet)

Example 4 with CharHashSet

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);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CharHashSet(org.eclipse.collections.impl.set.mutable.primitive.CharHashSet) Test(org.junit.Test)

Example 5 with CharHashSet

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();
}
Also used : MutableCharSet(org.eclipse.collections.api.set.primitive.MutableCharSet) CharHashSet(org.eclipse.collections.impl.set.mutable.primitive.CharHashSet)

Aggregations

CharHashSet (org.eclipse.collections.impl.set.mutable.primitive.CharHashSet)6 MutableCharSet (org.eclipse.collections.api.set.primitive.MutableCharSet)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Test (org.junit.Test)1