Search in sources :

Example 1 with ImmutableCollection

use of org.eclipse.collections.api.collection.ImmutableCollection in project eclipse-collections by eclipse.

the class AbstractImmutableCollectionTestCase method collectLong.

@Test
public void collectLong() {
    ImmutableCollection<Integer> integers = this.classUnderTest();
    ImmutableLongCollection immutableCollection = integers.collectLong(PrimitiveFunctions.unboxIntegerToLong());
    Verify.assertSize(integers.size(), immutableCollection);
    Assert.assertEquals(integers, immutableCollection.collect(longParameter -> Integer.valueOf((int) longParameter)));
}
Also used : Predicate(org.eclipse.collections.api.block.predicate.Predicate) SortedBags(org.eclipse.collections.impl.factory.SortedBags) Verify(org.eclipse.collections.impl.test.Verify) MutableBag(org.eclipse.collections.api.bag.MutableBag) MutableList(org.eclipse.collections.api.list.MutableList) ImmutableBooleanCollection(org.eclipse.collections.api.collection.primitive.ImmutableBooleanCollection) ImmutableDoubleCollection(org.eclipse.collections.api.collection.primitive.ImmutableDoubleCollection) RichIterable(org.eclipse.collections.api.RichIterable) ImmutableLongCollection(org.eclipse.collections.api.collection.primitive.ImmutableLongCollection) ImmutableShortCollection(org.eclipse.collections.api.collection.primitive.ImmutableShortCollection) Functions(org.eclipse.collections.impl.block.factory.Functions) Interval(org.eclipse.collections.impl.list.Interval) Comparators(org.eclipse.collections.impl.block.factory.Comparators) Collection(java.util.Collection) Procedures(org.eclipse.collections.impl.block.factory.Procedures) ImmutableObjectLongMap(org.eclipse.collections.api.map.primitive.ImmutableObjectLongMap) MutableSortedSet(org.eclipse.collections.api.set.sorted.MutableSortedSet) TreeSortedSet(org.eclipse.collections.impl.set.sorted.mutable.TreeSortedSet) Procedure2(org.eclipse.collections.api.block.procedure.Procedure2) Iterables.iList(org.eclipse.collections.impl.factory.Iterables.iList) Lists(org.eclipse.collections.impl.factory.Lists) Optional(java.util.Optional) ImmutableIntCollection(org.eclipse.collections.api.collection.primitive.ImmutableIntCollection) Bag(org.eclipse.collections.api.bag.Bag) ImmutableCollection(org.eclipse.collections.api.collection.ImmutableCollection) PartitionImmutableCollection(org.eclipse.collections.api.partition.PartitionImmutableCollection) Supplier(java.util.function.Supplier) FastList(org.eclipse.collections.impl.list.mutable.FastList) Function0(org.eclipse.collections.api.block.function.Function0) Function2(org.eclipse.collections.api.block.function.Function2) ImmutableObjectDoubleMap(org.eclipse.collections.api.map.primitive.ImmutableObjectDoubleMap) NoSuchElementException(java.util.NoSuchElementException) MutableCollection(org.eclipse.collections.api.collection.MutableCollection) ImmutableCharCollection(org.eclipse.collections.api.collection.primitive.ImmutableCharCollection) PrimitiveFunctions(org.eclipse.collections.impl.block.factory.PrimitiveFunctions) Predicates(org.eclipse.collections.impl.block.factory.Predicates) Counter(org.eclipse.collections.impl.Counter) Predicates2(org.eclipse.collections.impl.block.factory.Predicates2) Collectors2(org.eclipse.collections.impl.collector.Collectors2) Iterator(java.util.Iterator) ImmutableByteCollection(org.eclipse.collections.api.collection.primitive.ImmutableByteCollection) IntegerPredicates(org.eclipse.collections.impl.block.factory.IntegerPredicates) Bags(org.eclipse.collections.impl.factory.Bags) Test(org.junit.Test) PassThruFunction0(org.eclipse.collections.impl.block.function.PassThruFunction0) MapIterable(org.eclipse.collections.api.map.MapIterable) AddFunction(org.eclipse.collections.impl.block.function.AddFunction) ImmutableFloatCollection(org.eclipse.collections.api.collection.primitive.ImmutableFloatCollection) Assert(org.junit.Assert) Collections(java.util.Collections) ImmutableLongCollection(org.eclipse.collections.api.collection.primitive.ImmutableLongCollection) Test(org.junit.Test)

Example 2 with ImmutableCollection

use of org.eclipse.collections.api.collection.ImmutableCollection in project eclipse-collections by eclipse.

the class AbstractImmutableCollectionTestCase method collectFloat.

@Test
public void collectFloat() {
    ImmutableCollection<Integer> integers = this.classUnderTest();
    ImmutableFloatCollection immutableCollection = integers.collectFloat(PrimitiveFunctions.unboxIntegerToFloat());
    Verify.assertSize(integers.size(), immutableCollection);
    Assert.assertEquals(integers, immutableCollection.collect(floatParameter -> Integer.valueOf((int) floatParameter)));
}
Also used : Predicate(org.eclipse.collections.api.block.predicate.Predicate) SortedBags(org.eclipse.collections.impl.factory.SortedBags) Verify(org.eclipse.collections.impl.test.Verify) MutableBag(org.eclipse.collections.api.bag.MutableBag) MutableList(org.eclipse.collections.api.list.MutableList) ImmutableBooleanCollection(org.eclipse.collections.api.collection.primitive.ImmutableBooleanCollection) ImmutableDoubleCollection(org.eclipse.collections.api.collection.primitive.ImmutableDoubleCollection) RichIterable(org.eclipse.collections.api.RichIterable) ImmutableLongCollection(org.eclipse.collections.api.collection.primitive.ImmutableLongCollection) ImmutableShortCollection(org.eclipse.collections.api.collection.primitive.ImmutableShortCollection) Functions(org.eclipse.collections.impl.block.factory.Functions) Interval(org.eclipse.collections.impl.list.Interval) Comparators(org.eclipse.collections.impl.block.factory.Comparators) Collection(java.util.Collection) Procedures(org.eclipse.collections.impl.block.factory.Procedures) ImmutableObjectLongMap(org.eclipse.collections.api.map.primitive.ImmutableObjectLongMap) MutableSortedSet(org.eclipse.collections.api.set.sorted.MutableSortedSet) TreeSortedSet(org.eclipse.collections.impl.set.sorted.mutable.TreeSortedSet) Procedure2(org.eclipse.collections.api.block.procedure.Procedure2) Iterables.iList(org.eclipse.collections.impl.factory.Iterables.iList) Lists(org.eclipse.collections.impl.factory.Lists) Optional(java.util.Optional) ImmutableIntCollection(org.eclipse.collections.api.collection.primitive.ImmutableIntCollection) Bag(org.eclipse.collections.api.bag.Bag) ImmutableCollection(org.eclipse.collections.api.collection.ImmutableCollection) PartitionImmutableCollection(org.eclipse.collections.api.partition.PartitionImmutableCollection) Supplier(java.util.function.Supplier) FastList(org.eclipse.collections.impl.list.mutable.FastList) Function0(org.eclipse.collections.api.block.function.Function0) Function2(org.eclipse.collections.api.block.function.Function2) ImmutableObjectDoubleMap(org.eclipse.collections.api.map.primitive.ImmutableObjectDoubleMap) NoSuchElementException(java.util.NoSuchElementException) MutableCollection(org.eclipse.collections.api.collection.MutableCollection) ImmutableCharCollection(org.eclipse.collections.api.collection.primitive.ImmutableCharCollection) PrimitiveFunctions(org.eclipse.collections.impl.block.factory.PrimitiveFunctions) Predicates(org.eclipse.collections.impl.block.factory.Predicates) Counter(org.eclipse.collections.impl.Counter) Predicates2(org.eclipse.collections.impl.block.factory.Predicates2) Collectors2(org.eclipse.collections.impl.collector.Collectors2) Iterator(java.util.Iterator) ImmutableByteCollection(org.eclipse.collections.api.collection.primitive.ImmutableByteCollection) IntegerPredicates(org.eclipse.collections.impl.block.factory.IntegerPredicates) Bags(org.eclipse.collections.impl.factory.Bags) Test(org.junit.Test) PassThruFunction0(org.eclipse.collections.impl.block.function.PassThruFunction0) MapIterable(org.eclipse.collections.api.map.MapIterable) AddFunction(org.eclipse.collections.impl.block.function.AddFunction) ImmutableFloatCollection(org.eclipse.collections.api.collection.primitive.ImmutableFloatCollection) Assert(org.junit.Assert) Collections(java.util.Collections) ImmutableFloatCollection(org.eclipse.collections.api.collection.primitive.ImmutableFloatCollection) Test(org.junit.Test)

Example 3 with ImmutableCollection

use of org.eclipse.collections.api.collection.ImmutableCollection in project eclipse-collections by eclipse.

the class AbstractImmutableCollectionTestCase method collectDouble.

@Test
public void collectDouble() {
    ImmutableCollection<Integer> integers = this.classUnderTest();
    ImmutableDoubleCollection immutableCollection = integers.collectDouble(PrimitiveFunctions.unboxIntegerToDouble());
    Verify.assertSize(integers.size(), immutableCollection);
    Assert.assertEquals(integers, immutableCollection.collect(doubleParameter -> Integer.valueOf((int) doubleParameter)));
}
Also used : Predicate(org.eclipse.collections.api.block.predicate.Predicate) SortedBags(org.eclipse.collections.impl.factory.SortedBags) Verify(org.eclipse.collections.impl.test.Verify) MutableBag(org.eclipse.collections.api.bag.MutableBag) MutableList(org.eclipse.collections.api.list.MutableList) ImmutableBooleanCollection(org.eclipse.collections.api.collection.primitive.ImmutableBooleanCollection) ImmutableDoubleCollection(org.eclipse.collections.api.collection.primitive.ImmutableDoubleCollection) RichIterable(org.eclipse.collections.api.RichIterable) ImmutableLongCollection(org.eclipse.collections.api.collection.primitive.ImmutableLongCollection) ImmutableShortCollection(org.eclipse.collections.api.collection.primitive.ImmutableShortCollection) Functions(org.eclipse.collections.impl.block.factory.Functions) Interval(org.eclipse.collections.impl.list.Interval) Comparators(org.eclipse.collections.impl.block.factory.Comparators) Collection(java.util.Collection) Procedures(org.eclipse.collections.impl.block.factory.Procedures) ImmutableObjectLongMap(org.eclipse.collections.api.map.primitive.ImmutableObjectLongMap) MutableSortedSet(org.eclipse.collections.api.set.sorted.MutableSortedSet) TreeSortedSet(org.eclipse.collections.impl.set.sorted.mutable.TreeSortedSet) Procedure2(org.eclipse.collections.api.block.procedure.Procedure2) Iterables.iList(org.eclipse.collections.impl.factory.Iterables.iList) Lists(org.eclipse.collections.impl.factory.Lists) Optional(java.util.Optional) ImmutableIntCollection(org.eclipse.collections.api.collection.primitive.ImmutableIntCollection) Bag(org.eclipse.collections.api.bag.Bag) ImmutableCollection(org.eclipse.collections.api.collection.ImmutableCollection) PartitionImmutableCollection(org.eclipse.collections.api.partition.PartitionImmutableCollection) Supplier(java.util.function.Supplier) FastList(org.eclipse.collections.impl.list.mutable.FastList) Function0(org.eclipse.collections.api.block.function.Function0) Function2(org.eclipse.collections.api.block.function.Function2) ImmutableObjectDoubleMap(org.eclipse.collections.api.map.primitive.ImmutableObjectDoubleMap) NoSuchElementException(java.util.NoSuchElementException) MutableCollection(org.eclipse.collections.api.collection.MutableCollection) ImmutableCharCollection(org.eclipse.collections.api.collection.primitive.ImmutableCharCollection) PrimitiveFunctions(org.eclipse.collections.impl.block.factory.PrimitiveFunctions) Predicates(org.eclipse.collections.impl.block.factory.Predicates) Counter(org.eclipse.collections.impl.Counter) Predicates2(org.eclipse.collections.impl.block.factory.Predicates2) Collectors2(org.eclipse.collections.impl.collector.Collectors2) Iterator(java.util.Iterator) ImmutableByteCollection(org.eclipse.collections.api.collection.primitive.ImmutableByteCollection) IntegerPredicates(org.eclipse.collections.impl.block.factory.IntegerPredicates) Bags(org.eclipse.collections.impl.factory.Bags) Test(org.junit.Test) PassThruFunction0(org.eclipse.collections.impl.block.function.PassThruFunction0) MapIterable(org.eclipse.collections.api.map.MapIterable) AddFunction(org.eclipse.collections.impl.block.function.AddFunction) ImmutableFloatCollection(org.eclipse.collections.api.collection.primitive.ImmutableFloatCollection) Assert(org.junit.Assert) Collections(java.util.Collections) ImmutableDoubleCollection(org.eclipse.collections.api.collection.primitive.ImmutableDoubleCollection) Test(org.junit.Test)

Aggregations

Collection (java.util.Collection)3 Collections (java.util.Collections)3 Iterator (java.util.Iterator)3 NoSuchElementException (java.util.NoSuchElementException)3 Optional (java.util.Optional)3 Supplier (java.util.function.Supplier)3 RichIterable (org.eclipse.collections.api.RichIterable)3 Bag (org.eclipse.collections.api.bag.Bag)3 MutableBag (org.eclipse.collections.api.bag.MutableBag)3 Function0 (org.eclipse.collections.api.block.function.Function0)3 Function2 (org.eclipse.collections.api.block.function.Function2)3 Predicate (org.eclipse.collections.api.block.predicate.Predicate)3 Procedure2 (org.eclipse.collections.api.block.procedure.Procedure2)3 ImmutableCollection (org.eclipse.collections.api.collection.ImmutableCollection)3 MutableCollection (org.eclipse.collections.api.collection.MutableCollection)3 ImmutableBooleanCollection (org.eclipse.collections.api.collection.primitive.ImmutableBooleanCollection)3 ImmutableByteCollection (org.eclipse.collections.api.collection.primitive.ImmutableByteCollection)3 ImmutableCharCollection (org.eclipse.collections.api.collection.primitive.ImmutableCharCollection)3 ImmutableDoubleCollection (org.eclipse.collections.api.collection.primitive.ImmutableDoubleCollection)3 ImmutableFloatCollection (org.eclipse.collections.api.collection.primitive.ImmutableFloatCollection)3