Search in sources :

Example 1 with BooleanList

use of org.eclipse.collections.api.list.primitive.BooleanList in project eclipse-collections by eclipse.

the class Collectors2AdditionalTest method collectBoolean.

@Test
public void collectBoolean() {
    BooleanList expected = SMALL_INTERVAL.collectBoolean(each -> each % 2 == 0, BooleanLists.mutable.empty());
    BooleanList actual = this.smallData.stream().collect(Collectors2.collectBoolean(each -> each % 2 == 0, BooleanLists.mutable::empty));
    Assert.assertEquals(expected, actual);
}
Also used : BooleanList(org.eclipse.collections.api.list.primitive.BooleanList) 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) BooleanLists(org.eclipse.collections.impl.factory.primitive.BooleanLists) Test(org.junit.Test)

Example 2 with BooleanList

use of org.eclipse.collections.api.list.primitive.BooleanList in project eclipse-collections by eclipse.

the class Collectors2AdditionalTest method collectBooleanParallel.

@Test
public void collectBooleanParallel() {
    BooleanList expected = LARGE_INTERVAL.collectBoolean(each -> each % 2 == 0, BooleanLists.mutable.empty());
    BooleanList actual = this.bigData.parallelStream().collect(Collectors2.collectBoolean(each -> each % 2 == 0, BooleanLists.mutable::empty));
    Assert.assertEquals(expected, actual);
}
Also used : BooleanList(org.eclipse.collections.api.list.primitive.BooleanList) 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) BooleanLists(org.eclipse.collections.impl.factory.primitive.BooleanLists) Test(org.junit.Test)

Example 3 with BooleanList

use of org.eclipse.collections.api.list.primitive.BooleanList in project eclipse-collections by eclipse.

the class BooleanCaseProcedureTest method noopCaseAndThenDefault.

@Test
public void noopCaseAndThenDefault() {
    MutableBooleanList result = BooleanLists.mutable.empty();
    BooleanList source = BooleanLists.mutable.with(true, false);
    BooleanCaseProcedure procedure = new BooleanCaseProcedure();
    source.each(procedure);
    Verify.assertEmpty(result);
    procedure.setDefault(result::add);
    source.each(procedure);
    Assert.assertEquals(result, source);
    Verify.assertContains("BooleanCaseProcedure", procedure.toString());
}
Also used : MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) BooleanList(org.eclipse.collections.api.list.primitive.BooleanList) MutableBooleanList(org.eclipse.collections.api.list.primitive.MutableBooleanList) Test(org.junit.Test)

Aggregations

BooleanList (org.eclipse.collections.api.list.primitive.BooleanList)3 Test (org.junit.Test)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 MutableList (org.eclipse.collections.api.list.MutableList)2 ByteList (org.eclipse.collections.api.list.primitive.ByteList)2 CharList (org.eclipse.collections.api.list.primitive.CharList)2 DoubleList (org.eclipse.collections.api.list.primitive.DoubleList)2 FloatList (org.eclipse.collections.api.list.primitive.FloatList)2 IntList (org.eclipse.collections.api.list.primitive.IntList)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 PartitionMutableSet (org.eclipse.collections.api.partition.set.PartitionMutableSet)2 Functions (org.eclipse.collections.impl.block.factory.Functions)2