use of org.eclipse.collections.impl.list.mutable.primitive.CharArrayList in project eclipse-collections by eclipse.
the class ImmutableEmptySortedBagTest method collectChar_target.
@Override
@Test
public void collectChar_target() {
ImmutableSortedBag<Integer> bag = this.classUnderTest();
Assert.assertEquals(new CharArrayList(), bag.collectChar(PrimitiveFunctions.unboxIntegerToChar(), new CharArrayList()));
ImmutableSortedBag<Integer> bag2 = this.classUnderTest();
Assert.assertEquals(new CharHashBag(), bag2.collectChar(PrimitiveFunctions.unboxIntegerToChar(), new CharHashBag()));
}
use of org.eclipse.collections.impl.list.mutable.primitive.CharArrayList in project eclipse-collections by eclipse.
the class OrderedMapAdapter method collectChar.
@Override
public MutableCharList collectChar(CharFunction<? super V> charFunction) {
CharArrayList result = new CharArrayList(this.size());
this.forEach(new CollectCharProcedure<>(charFunction, result));
return result;
}
use of org.eclipse.collections.impl.list.mutable.primitive.CharArrayList in project eclipse-collections by eclipse.
the class AbstractImmutableSortedSet method collectChar.
@Override
public ImmutableCharList collectChar(CharFunction<? super T> charFunction) {
CharArrayList result = new CharArrayList(this.size());
this.forEach(new CollectCharProcedure<>(charFunction, result));
return result.toImmutable();
}
use of org.eclipse.collections.impl.list.mutable.primitive.CharArrayList in project eclipse-collections by eclipse.
the class IterateTest method collectCharWithTarget.
@Test
public void collectCharWithTarget() {
this.iterables.each(each -> {
MutableCharCollection expected = new CharArrayList();
MutableCharCollection actual = Iterate.collectChar(each, PrimitiveFunctions.unboxIntegerToChar(), expected);
Assert.assertTrue(actual.containsAll((char) 1, (char) 2, (char) 3, (char) 4, (char) 5));
Assert.assertSame("Target list sent as parameter not returned", expected, actual);
});
Verify.assertThrows(IllegalArgumentException.class, () -> Iterate.collectChar(null, PrimitiveFunctions.unboxIntegerToChar(), new CharArrayList()));
}
use of org.eclipse.collections.impl.list.mutable.primitive.CharArrayList in project eclipse-collections by eclipse.
the class StringIterateTest method asCharAdapter.
@Test
public void asCharAdapter() {
CharAdapter answer = StringIterate.asCharAdapter("HelloHellow").collectChar(Character::toUpperCase).select(c -> c != 'W').distinct().toReversed().reject(CharAdapter.adapt("LE")::contains).newWith('!');
Assert.assertEquals("OH!", answer.toString());
Assert.assertEquals("OH!", answer.toStringBuilder().toString());
Assert.assertEquals("OH!", answer.makeString(""));
CharList charList = StringIterate.asCharAdapter("HelloHellow").asLazy().collectChar(Character::toUpperCase).select(c -> c != 'W').toList().distinct().toReversed().reject(CharAdapter.adapt("LE")::contains).with('!');
Assert.assertEquals("OH!", CharAdapter.from(charList).toString());
Assert.assertEquals("OH!", CharAdapter.from(CharAdapter.from(charList)).toString());
String helloUppercase2 = StringIterate.asCharAdapter("Hello").asLazy().collectChar(Character::toUpperCase).makeString("");
Assert.assertEquals("HELLO", helloUppercase2);
CharArrayList arraylist = new CharArrayList();
StringIterate.asCharAdapter("Hello".toUpperCase()).chars().sorted().forEach(e -> arraylist.add((char) e));
Assert.assertEquals(StringIterate.asCharAdapter("EHLLO"), arraylist);
ImmutableCharList arrayList2 = StringIterate.asCharAdapter("Hello".toUpperCase()).toSortedList().toImmutable();
Assert.assertEquals(StringIterate.asCharAdapter("EHLLO"), arrayList2);
Assert.assertEquals(StringIterate.asCharAdapter("HELLO"), CharAdapter.adapt("hello").collectChar(Character::toUpperCase));
}
Aggregations