use of org.eclipse.collections.api.list.primitive.CharList in project eclipse-collections by eclipse.
the class Collectors2AdditionalTest method collectChar.
@Test
public void collectChar() {
CharList expected = SMALL_INTERVAL.collectChar(each -> (char) (each % Character.MAX_VALUE), CharLists.mutable.empty());
CharList actual = this.smallData.stream().collect(Collectors2.collectChar(each -> (char) (each % Character.MAX_VALUE), CharLists.mutable::empty));
Assert.assertEquals(expected, actual);
}
use of org.eclipse.collections.api.list.primitive.CharList in project eclipse-collections by eclipse.
the class Collectors2AdditionalTest method collectCharParallel.
@Test
public void collectCharParallel() {
CharList expected = LARGE_INTERVAL.collectChar(each -> (char) (each % Character.MAX_VALUE), CharLists.mutable.empty());
CharList actual = this.bigData.parallelStream().collect(Collectors2.collectChar(each -> (char) (each % Character.MAX_VALUE), CharLists.mutable::empty));
Assert.assertEquals(expected, actual);
}
use of org.eclipse.collections.api.list.primitive.CharList 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