Search in sources :

Example 1 with CharList

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);
}
Also used : LongLists(org.eclipse.collections.impl.factory.primitive.LongLists) CompositeFastList(org.eclipse.collections.impl.list.mutable.CompositeFastList) LongList(org.eclipse.collections.api.list.primitive.LongList) PartitionMutableBag(org.eclipse.collections.api.partition.bag.PartitionMutableBag) DoubleLists(org.eclipse.collections.impl.factory.primitive.DoubleLists) Verify(org.eclipse.collections.impl.test.Verify) MutableList(org.eclipse.collections.api.list.MutableList) ShortList(org.eclipse.collections.api.list.primitive.ShortList) PartitionMutableSet(org.eclipse.collections.api.partition.set.PartitionMutableSet) ArrayList(java.util.ArrayList) PartitionFastList(org.eclipse.collections.impl.partition.list.PartitionFastList) BigDecimal(java.math.BigDecimal) Functions(org.eclipse.collections.impl.block.factory.Functions) ByteLists(org.eclipse.collections.impl.factory.primitive.ByteLists) Map(java.util.Map) Interval(org.eclipse.collections.impl.list.Interval) PartitionHashBag(org.eclipse.collections.impl.partition.bag.PartitionHashBag) PrimitiveTuples(org.eclipse.collections.impl.tuple.primitive.PrimitiveTuples) BigInteger(java.math.BigInteger) DoubleList(org.eclipse.collections.api.list.primitive.DoubleList) PartitionMutableList(org.eclipse.collections.api.partition.list.PartitionMutableList) Predicates2(org.eclipse.collections.impl.block.factory.Predicates2) CharLists(org.eclipse.collections.impl.factory.primitive.CharLists) CharList(org.eclipse.collections.api.list.primitive.CharList) IntList(org.eclipse.collections.api.list.primitive.IntList) IntegerPredicates(org.eclipse.collections.impl.block.factory.IntegerPredicates) Bags(org.eclipse.collections.impl.factory.Bags) BooleanLists(org.eclipse.collections.impl.factory.primitive.BooleanLists) PartitionUnifiedSet(org.eclipse.collections.impl.partition.set.PartitionUnifiedSet) Test(org.junit.Test) Iterate(org.eclipse.collections.impl.utility.Iterate) Collectors(java.util.stream.Collectors) BooleanList(org.eclipse.collections.api.list.primitive.BooleanList) FloatLists(org.eclipse.collections.impl.factory.primitive.FloatLists) List(java.util.List) ShortLists(org.eclipse.collections.impl.factory.primitive.ShortLists) ByteList(org.eclipse.collections.api.list.primitive.ByteList) IntLists(org.eclipse.collections.impl.factory.primitive.IntLists) FloatList(org.eclipse.collections.api.list.primitive.FloatList) Lists(org.eclipse.collections.impl.factory.Lists) Sets(org.eclipse.collections.impl.factory.Sets) Assert(org.junit.Assert) CharList(org.eclipse.collections.api.list.primitive.CharList) CharLists(org.eclipse.collections.impl.factory.primitive.CharLists) Test(org.junit.Test)

Example 2 with CharList

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);
}
Also used : LongLists(org.eclipse.collections.impl.factory.primitive.LongLists) CompositeFastList(org.eclipse.collections.impl.list.mutable.CompositeFastList) LongList(org.eclipse.collections.api.list.primitive.LongList) PartitionMutableBag(org.eclipse.collections.api.partition.bag.PartitionMutableBag) DoubleLists(org.eclipse.collections.impl.factory.primitive.DoubleLists) Verify(org.eclipse.collections.impl.test.Verify) MutableList(org.eclipse.collections.api.list.MutableList) ShortList(org.eclipse.collections.api.list.primitive.ShortList) PartitionMutableSet(org.eclipse.collections.api.partition.set.PartitionMutableSet) ArrayList(java.util.ArrayList) PartitionFastList(org.eclipse.collections.impl.partition.list.PartitionFastList) BigDecimal(java.math.BigDecimal) Functions(org.eclipse.collections.impl.block.factory.Functions) ByteLists(org.eclipse.collections.impl.factory.primitive.ByteLists) Map(java.util.Map) Interval(org.eclipse.collections.impl.list.Interval) PartitionHashBag(org.eclipse.collections.impl.partition.bag.PartitionHashBag) PrimitiveTuples(org.eclipse.collections.impl.tuple.primitive.PrimitiveTuples) BigInteger(java.math.BigInteger) DoubleList(org.eclipse.collections.api.list.primitive.DoubleList) PartitionMutableList(org.eclipse.collections.api.partition.list.PartitionMutableList) Predicates2(org.eclipse.collections.impl.block.factory.Predicates2) CharLists(org.eclipse.collections.impl.factory.primitive.CharLists) CharList(org.eclipse.collections.api.list.primitive.CharList) IntList(org.eclipse.collections.api.list.primitive.IntList) IntegerPredicates(org.eclipse.collections.impl.block.factory.IntegerPredicates) Bags(org.eclipse.collections.impl.factory.Bags) BooleanLists(org.eclipse.collections.impl.factory.primitive.BooleanLists) PartitionUnifiedSet(org.eclipse.collections.impl.partition.set.PartitionUnifiedSet) Test(org.junit.Test) Iterate(org.eclipse.collections.impl.utility.Iterate) Collectors(java.util.stream.Collectors) BooleanList(org.eclipse.collections.api.list.primitive.BooleanList) FloatLists(org.eclipse.collections.impl.factory.primitive.FloatLists) List(java.util.List) ShortLists(org.eclipse.collections.impl.factory.primitive.ShortLists) ByteList(org.eclipse.collections.api.list.primitive.ByteList) IntLists(org.eclipse.collections.impl.factory.primitive.IntLists) FloatList(org.eclipse.collections.api.list.primitive.FloatList) Lists(org.eclipse.collections.impl.factory.Lists) Sets(org.eclipse.collections.impl.factory.Sets) Assert(org.junit.Assert) CharList(org.eclipse.collections.api.list.primitive.CharList) CharLists(org.eclipse.collections.impl.factory.primitive.CharLists) Test(org.junit.Test)

Example 3 with CharList

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));
}
Also used : CharPredicates(org.eclipse.collections.impl.block.factory.primitive.CharPredicates) Function(org.eclipse.collections.api.block.function.Function) CodePointList(org.eclipse.collections.impl.string.immutable.CodePointList) CharProcedure(org.eclipse.collections.api.block.procedure.primitive.CharProcedure) Verify(org.eclipse.collections.impl.test.Verify) IntSets(org.eclipse.collections.impl.factory.primitive.IntSets) MutableBag(org.eclipse.collections.api.bag.MutableBag) MutableList(org.eclipse.collections.api.list.MutableList) FastList(org.eclipse.collections.impl.list.mutable.FastList) CharToCharFunctions(org.eclipse.collections.impl.block.factory.primitive.CharToCharFunctions) CodePointAdapter(org.eclipse.collections.impl.string.immutable.CodePointAdapter) MutableSet(org.eclipse.collections.api.set.MutableSet) CodePointPredicate(org.eclipse.collections.impl.block.predicate.CodePointPredicate) MutableMap(org.eclipse.collections.api.map.MutableMap) Functions(org.eclipse.collections.impl.block.factory.Functions) Tuples(org.eclipse.collections.impl.tuple.Tuples) CharAdapter(org.eclipse.collections.impl.string.immutable.CharAdapter) CharList(org.eclipse.collections.api.list.primitive.CharList) IntList(org.eclipse.collections.api.list.primitive.IntList) CodePointProcedure(org.eclipse.collections.impl.block.procedure.primitive.CodePointProcedure) Twin(org.eclipse.collections.api.tuple.Twin) CharArrayList(org.eclipse.collections.impl.list.mutable.primitive.CharArrayList) ImmutableCharList(org.eclipse.collections.api.list.primitive.ImmutableCharList) Procedures(org.eclipse.collections.impl.block.factory.Procedures) Test(org.junit.Test) CharSets(org.eclipse.collections.impl.factory.primitive.CharSets) Lists(org.eclipse.collections.impl.factory.Lists) AddFunction(org.eclipse.collections.impl.block.function.AddFunction) ImmutableIntSet(org.eclipse.collections.api.set.primitive.ImmutableIntSet) Assert(org.junit.Assert) ImmutableCharSet(org.eclipse.collections.api.set.primitive.ImmutableCharSet) CodePointFunction(org.eclipse.collections.impl.block.function.primitive.CodePointFunction) UnifiedSet(org.eclipse.collections.impl.set.mutable.UnifiedSet) CharArrayList(org.eclipse.collections.impl.list.mutable.primitive.CharArrayList) CharAdapter(org.eclipse.collections.impl.string.immutable.CharAdapter) CharList(org.eclipse.collections.api.list.primitive.CharList) ImmutableCharList(org.eclipse.collections.api.list.primitive.ImmutableCharList) ImmutableCharList(org.eclipse.collections.api.list.primitive.ImmutableCharList) Test(org.junit.Test)

Aggregations

MutableList (org.eclipse.collections.api.list.MutableList)3 CharList (org.eclipse.collections.api.list.primitive.CharList)3 IntList (org.eclipse.collections.api.list.primitive.IntList)3 Functions (org.eclipse.collections.impl.block.factory.Functions)3 Lists (org.eclipse.collections.impl.factory.Lists)3 Verify (org.eclipse.collections.impl.test.Verify)3 BigDecimal (java.math.BigDecimal)2 BigInteger (java.math.BigInteger)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 BooleanList (org.eclipse.collections.api.list.primitive.BooleanList)2 ByteList (org.eclipse.collections.api.list.primitive.ByteList)2 DoubleList (org.eclipse.collections.api.list.primitive.DoubleList)2 FloatList (org.eclipse.collections.api.list.primitive.FloatList)2 LongList (org.eclipse.collections.api.list.primitive.LongList)2 ShortList (org.eclipse.collections.api.list.primitive.ShortList)2 PartitionMutableBag (org.eclipse.collections.api.partition.bag.PartitionMutableBag)2 PartitionMutableList (org.eclipse.collections.api.partition.list.PartitionMutableList)2