Search in sources :

Example 1 with MapIterable

use of org.eclipse.collections.api.map.MapIterable in project eclipse-collections by eclipse.

the class MapIterableTestCase method collectCharWithTarget.

@Test
public void collectCharWithTarget() {
    CharHashBag target = new CharHashBag();
    MapIterable<String, String> map = this.newMapWithKeysValues("One", "A1", "Two", "B", "Three", "C#++");
    CharHashBag result = map.collectChar((CharFunction<String>) string -> string.charAt(0), target);
    Assert.assertSame("Target sent as parameter not returned", target, result);
    Assert.assertEquals(CharHashBag.newBagWith('A', 'B', 'C'), result.toBag());
}
Also used : Maps(org.eclipse.collections.impl.factory.Maps) CharHashBag(org.eclipse.collections.impl.bag.mutable.primitive.CharHashBag) CharFunction(org.eclipse.collections.api.block.function.primitive.CharFunction) Multimap(org.eclipse.collections.api.multimap.Multimap) Verify(org.eclipse.collections.impl.test.Verify) StringFunctions(org.eclipse.collections.impl.block.factory.StringFunctions) MutableBag(org.eclipse.collections.api.bag.MutableBag) MutableList(org.eclipse.collections.api.list.MutableList) FastListMultimap(org.eclipse.collections.impl.multimap.list.FastListMultimap) UnifiedSetMultimap(org.eclipse.collections.impl.multimap.set.UnifiedSetMultimap) MutableSet(org.eclipse.collections.api.set.MutableSet) RichIterable(org.eclipse.collections.api.RichIterable) IntegerWithCast(org.eclipse.collections.impl.IntegerWithCast) HashBag(org.eclipse.collections.impl.bag.mutable.HashBag) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Functions(org.eclipse.collections.impl.block.factory.Functions) Map(java.util.Map) LongIterable(org.eclipse.collections.api.LongIterable) MutableMultimap(org.eclipse.collections.api.multimap.MutableMultimap) Tuples(org.eclipse.collections.impl.tuple.Tuples) Interval(org.eclipse.collections.impl.list.Interval) ShortHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag) Comparators(org.eclipse.collections.impl.block.factory.Comparators) DoubleHashBag(org.eclipse.collections.impl.bag.mutable.primitive.DoubleHashBag) UnifiedMap(org.eclipse.collections.impl.map.mutable.UnifiedMap) CollectionAddProcedure(org.eclipse.collections.impl.block.procedure.CollectionAddProcedure) SumProcedure(org.eclipse.collections.impl.math.SumProcedure) MutableSortedBag(org.eclipse.collections.api.bag.sorted.MutableSortedBag) ObjectDoubleMap(org.eclipse.collections.api.map.primitive.ObjectDoubleMap) ByteHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) CharIterable(org.eclipse.collections.api.CharIterable) MutableSortedSet(org.eclipse.collections.api.set.sorted.MutableSortedSet) TreeSortedSet(org.eclipse.collections.impl.set.sorted.mutable.TreeSortedSet) List(java.util.List) ObjectLongMap(org.eclipse.collections.api.map.primitive.ObjectLongMap) DoubleIterable(org.eclipse.collections.api.DoubleIterable) Lists(org.eclipse.collections.impl.factory.Lists) SortedMap(java.util.SortedMap) NegativeIntervalFunction(org.eclipse.collections.impl.block.function.NegativeIntervalFunction) FloatIterable(org.eclipse.collections.api.FloatIterable) Function(org.eclipse.collections.api.block.function.Function) IntIterable(org.eclipse.collections.api.IntIterable) Bag(org.eclipse.collections.api.bag.Bag) Iterables.iBag(org.eclipse.collections.impl.factory.Iterables.iBag) Sum(org.eclipse.collections.impl.math.Sum) LongHashBag(org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag) FastList(org.eclipse.collections.impl.list.mutable.FastList) ConcurrentMap(java.util.concurrent.ConcurrentMap) LazyIterable(org.eclipse.collections.api.LazyIterable) Function0(org.eclipse.collections.api.block.function.Function0) MutableMap(org.eclipse.collections.api.map.MutableMap) Function2(org.eclipse.collections.api.block.function.Function2) TreeBag(org.eclipse.collections.impl.bag.sorted.mutable.TreeBag) ByteIterable(org.eclipse.collections.api.ByteIterable) MutableSetMultimap(org.eclipse.collections.api.multimap.set.MutableSetMultimap) CharAdapter(org.eclipse.collections.impl.string.immutable.CharAdapter) SerializeTestHelper(org.eclipse.collections.impl.test.SerializeTestHelper) Pair(org.eclipse.collections.api.tuple.Pair) Predicates(org.eclipse.collections.impl.block.factory.Predicates) Predicates2(org.eclipse.collections.impl.block.factory.Predicates2) Iterator(java.util.Iterator) BooleanIterable(org.eclipse.collections.api.BooleanIterable) IntegerPredicates(org.eclipse.collections.impl.block.factory.IntegerPredicates) ShortIterable(org.eclipse.collections.api.ShortIterable) Bags(org.eclipse.collections.impl.factory.Bags) TreeSortedMap(org.eclipse.collections.impl.map.sorted.mutable.TreeSortedMap) Test(org.junit.Test) PassThruFunction0(org.eclipse.collections.impl.block.function.PassThruFunction0) Iterables.iSet(org.eclipse.collections.impl.factory.Iterables.iSet) IntegerSum(org.eclipse.collections.impl.math.IntegerSum) MapIterable(org.eclipse.collections.api.map.MapIterable) PartitionIterable(org.eclipse.collections.api.partition.PartitionIterable) AddFunction(org.eclipse.collections.impl.block.function.AddFunction) FloatHashBag(org.eclipse.collections.impl.bag.mutable.primitive.FloatHashBag) Assert(org.junit.Assert) Collections(java.util.Collections) IntHashBag(org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag) UnifiedSet(org.eclipse.collections.impl.set.mutable.UnifiedSet) CharHashBag(org.eclipse.collections.impl.bag.mutable.primitive.CharHashBag) Test(org.junit.Test)

Example 2 with MapIterable

use of org.eclipse.collections.api.map.MapIterable in project eclipse-collections by eclipse.

the class MapIterableTestCase method collectChar.

@Test
public void collectChar() {
    MapIterable<String, String> map = this.newMapWithKeysValues("One", "A1", "Two", "B", "Three", "C#++");
    CharIterable actual = map.collectChar((CharFunction<String>) string -> string.charAt(0));
    Assert.assertEquals(CharHashBag.newBagWith('A', 'B', 'C'), actual.toBag());
}
Also used : Maps(org.eclipse.collections.impl.factory.Maps) CharHashBag(org.eclipse.collections.impl.bag.mutable.primitive.CharHashBag) CharFunction(org.eclipse.collections.api.block.function.primitive.CharFunction) Multimap(org.eclipse.collections.api.multimap.Multimap) Verify(org.eclipse.collections.impl.test.Verify) StringFunctions(org.eclipse.collections.impl.block.factory.StringFunctions) MutableBag(org.eclipse.collections.api.bag.MutableBag) MutableList(org.eclipse.collections.api.list.MutableList) FastListMultimap(org.eclipse.collections.impl.multimap.list.FastListMultimap) UnifiedSetMultimap(org.eclipse.collections.impl.multimap.set.UnifiedSetMultimap) MutableSet(org.eclipse.collections.api.set.MutableSet) RichIterable(org.eclipse.collections.api.RichIterable) IntegerWithCast(org.eclipse.collections.impl.IntegerWithCast) HashBag(org.eclipse.collections.impl.bag.mutable.HashBag) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Functions(org.eclipse.collections.impl.block.factory.Functions) Map(java.util.Map) LongIterable(org.eclipse.collections.api.LongIterable) MutableMultimap(org.eclipse.collections.api.multimap.MutableMultimap) Tuples(org.eclipse.collections.impl.tuple.Tuples) Interval(org.eclipse.collections.impl.list.Interval) ShortHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag) Comparators(org.eclipse.collections.impl.block.factory.Comparators) DoubleHashBag(org.eclipse.collections.impl.bag.mutable.primitive.DoubleHashBag) UnifiedMap(org.eclipse.collections.impl.map.mutable.UnifiedMap) CollectionAddProcedure(org.eclipse.collections.impl.block.procedure.CollectionAddProcedure) SumProcedure(org.eclipse.collections.impl.math.SumProcedure) MutableSortedBag(org.eclipse.collections.api.bag.sorted.MutableSortedBag) ObjectDoubleMap(org.eclipse.collections.api.map.primitive.ObjectDoubleMap) ByteHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) CharIterable(org.eclipse.collections.api.CharIterable) MutableSortedSet(org.eclipse.collections.api.set.sorted.MutableSortedSet) TreeSortedSet(org.eclipse.collections.impl.set.sorted.mutable.TreeSortedSet) List(java.util.List) ObjectLongMap(org.eclipse.collections.api.map.primitive.ObjectLongMap) DoubleIterable(org.eclipse.collections.api.DoubleIterable) Lists(org.eclipse.collections.impl.factory.Lists) SortedMap(java.util.SortedMap) NegativeIntervalFunction(org.eclipse.collections.impl.block.function.NegativeIntervalFunction) FloatIterable(org.eclipse.collections.api.FloatIterable) Function(org.eclipse.collections.api.block.function.Function) IntIterable(org.eclipse.collections.api.IntIterable) Bag(org.eclipse.collections.api.bag.Bag) Iterables.iBag(org.eclipse.collections.impl.factory.Iterables.iBag) Sum(org.eclipse.collections.impl.math.Sum) LongHashBag(org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag) FastList(org.eclipse.collections.impl.list.mutable.FastList) ConcurrentMap(java.util.concurrent.ConcurrentMap) LazyIterable(org.eclipse.collections.api.LazyIterable) Function0(org.eclipse.collections.api.block.function.Function0) MutableMap(org.eclipse.collections.api.map.MutableMap) Function2(org.eclipse.collections.api.block.function.Function2) TreeBag(org.eclipse.collections.impl.bag.sorted.mutable.TreeBag) ByteIterable(org.eclipse.collections.api.ByteIterable) MutableSetMultimap(org.eclipse.collections.api.multimap.set.MutableSetMultimap) CharAdapter(org.eclipse.collections.impl.string.immutable.CharAdapter) SerializeTestHelper(org.eclipse.collections.impl.test.SerializeTestHelper) Pair(org.eclipse.collections.api.tuple.Pair) Predicates(org.eclipse.collections.impl.block.factory.Predicates) Predicates2(org.eclipse.collections.impl.block.factory.Predicates2) Iterator(java.util.Iterator) BooleanIterable(org.eclipse.collections.api.BooleanIterable) IntegerPredicates(org.eclipse.collections.impl.block.factory.IntegerPredicates) ShortIterable(org.eclipse.collections.api.ShortIterable) Bags(org.eclipse.collections.impl.factory.Bags) TreeSortedMap(org.eclipse.collections.impl.map.sorted.mutable.TreeSortedMap) Test(org.junit.Test) PassThruFunction0(org.eclipse.collections.impl.block.function.PassThruFunction0) Iterables.iSet(org.eclipse.collections.impl.factory.Iterables.iSet) IntegerSum(org.eclipse.collections.impl.math.IntegerSum) MapIterable(org.eclipse.collections.api.map.MapIterable) PartitionIterable(org.eclipse.collections.api.partition.PartitionIterable) AddFunction(org.eclipse.collections.impl.block.function.AddFunction) FloatHashBag(org.eclipse.collections.impl.bag.mutable.primitive.FloatHashBag) Assert(org.junit.Assert) Collections(java.util.Collections) IntHashBag(org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag) UnifiedSet(org.eclipse.collections.impl.set.mutable.UnifiedSet) CharIterable(org.eclipse.collections.api.CharIterable) Test(org.junit.Test)

Aggregations

Collections (java.util.Collections)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Map (java.util.Map)2 SortedMap (java.util.SortedMap)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 BooleanIterable (org.eclipse.collections.api.BooleanIterable)2 ByteIterable (org.eclipse.collections.api.ByteIterable)2 CharIterable (org.eclipse.collections.api.CharIterable)2 DoubleIterable (org.eclipse.collections.api.DoubleIterable)2 FloatIterable (org.eclipse.collections.api.FloatIterable)2 IntIterable (org.eclipse.collections.api.IntIterable)2 LazyIterable (org.eclipse.collections.api.LazyIterable)2 LongIterable (org.eclipse.collections.api.LongIterable)2 RichIterable (org.eclipse.collections.api.RichIterable)2 ShortIterable (org.eclipse.collections.api.ShortIterable)2 Bag (org.eclipse.collections.api.bag.Bag)2 MutableBag (org.eclipse.collections.api.bag.MutableBag)2 MutableSortedBag (org.eclipse.collections.api.bag.sorted.MutableSortedBag)2