Search in sources :

Example 1 with ImmutableCharBag

use of org.eclipse.collections.api.bag.primitive.ImmutableCharBag in project eclipse-collections by eclipse.

the class ImmutableBagTestCase method collectChar.

@Override
@Test
public void collectChar() {
    super.collectChar();
    ImmutableCharBag result = this.newBag().collectChar((CharFunction<String>) string -> string.charAt(0));
    Assert.assertEquals(this.numKeys(), result.sizeDistinct());
    for (int i = 1; i <= this.numKeys(); i++) {
        Assert.assertEquals(i, result.occurrencesOf((char) ('0' + i)));
    }
}
Also used : 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) ObjectIntPair(org.eclipse.collections.api.tuple.primitive.ObjectIntPair) Verify(org.eclipse.collections.impl.test.Verify) MutableBag(org.eclipse.collections.api.bag.MutableBag) MutableList(org.eclipse.collections.api.list.MutableList) MutableSortedMap(org.eclipse.collections.api.map.sorted.MutableSortedMap) ImmutableShortBag(org.eclipse.collections.api.bag.primitive.ImmutableShortBag) MutableSet(org.eclipse.collections.api.set.MutableSet) HashBag(org.eclipse.collections.impl.bag.mutable.HashBag) Functions(org.eclipse.collections.impl.block.factory.Functions) MutableMultimap(org.eclipse.collections.api.multimap.MutableMultimap) 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) AbstractRichIterableTestCase(org.eclipse.collections.impl.AbstractRichIterableTestCase) CollectionAddProcedure(org.eclipse.collections.impl.block.procedure.CollectionAddProcedure) PartitionImmutableBag(org.eclipse.collections.api.partition.bag.PartitionImmutableBag) Collection(java.util.Collection) Set(java.util.Set) MutableSortedBag(org.eclipse.collections.api.bag.sorted.MutableSortedBag) ByteHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag) BooleanHashBag(org.eclipse.collections.impl.bag.mutable.primitive.BooleanHashBag) ImmutableFloatBag(org.eclipse.collections.api.bag.primitive.ImmutableFloatBag) List(java.util.List) Lists(org.eclipse.collections.impl.factory.Lists) NegativeIntervalFunction(org.eclipse.collections.impl.block.function.NegativeIntervalFunction) Function(org.eclipse.collections.api.block.function.Function) Bag(org.eclipse.collections.api.bag.Bag) ImmutableCharBag(org.eclipse.collections.api.bag.primitive.ImmutableCharBag) ImmutableDoubleBag(org.eclipse.collections.api.bag.primitive.ImmutableDoubleBag) LongHashBag(org.eclipse.collections.impl.bag.mutable.primitive.LongHashBag) FastList(org.eclipse.collections.impl.list.mutable.FastList) LazyIterable(org.eclipse.collections.api.LazyIterable) ImmutableBagMultimap(org.eclipse.collections.api.multimap.bag.ImmutableBagMultimap) Function0(org.eclipse.collections.api.block.function.Function0) MutableMap(org.eclipse.collections.api.map.MutableMap) HashBagMultimap(org.eclipse.collections.impl.multimap.bag.HashBagMultimap) Function2(org.eclipse.collections.api.block.function.Function2) TreeBag(org.eclipse.collections.impl.bag.sorted.mutable.TreeBag) PrimitiveTuples(org.eclipse.collections.impl.tuple.primitive.PrimitiveTuples) ImmutableBag(org.eclipse.collections.api.bag.ImmutableBag) ImmutableByteBag(org.eclipse.collections.api.bag.primitive.ImmutableByteBag) NoSuchElementException(java.util.NoSuchElementException) Pair(org.eclipse.collections.api.tuple.Pair) StringIterate(org.eclipse.collections.impl.utility.StringIterate) ImmutableIntBag(org.eclipse.collections.api.bag.primitive.ImmutableIntBag) Predicates(org.eclipse.collections.impl.block.factory.Predicates) Predicates2(org.eclipse.collections.impl.block.factory.Predicates2) Iterator(java.util.Iterator) IntegerPredicates(org.eclipse.collections.impl.block.factory.IntegerPredicates) Bags(org.eclipse.collections.impl.factory.Bags) IntPredicates(org.eclipse.collections.impl.block.factory.primitive.IntPredicates) Test(org.junit.Test) PassThruFunction0(org.eclipse.collections.impl.block.function.PassThruFunction0) ImmutableBooleanBag(org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag) ObjectIntProcedures(org.eclipse.collections.impl.block.factory.ObjectIntProcedures) Sets(org.eclipse.collections.impl.factory.Sets) ImmutableLongBag(org.eclipse.collections.api.bag.primitive.ImmutableLongBag) MapIterable(org.eclipse.collections.api.map.MapIterable) AddFunction(org.eclipse.collections.impl.block.function.AddFunction) ImmutableSet(org.eclipse.collections.api.set.ImmutableSet) Comparator(java.util.Comparator) 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) ImmutableCharBag(org.eclipse.collections.api.bag.primitive.ImmutableCharBag) Test(org.junit.Test)

Aggregations

Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Iterator (java.util.Iterator)1 List (java.util.List)1 NoSuchElementException (java.util.NoSuchElementException)1 Set (java.util.Set)1 LazyIterable (org.eclipse.collections.api.LazyIterable)1 Bag (org.eclipse.collections.api.bag.Bag)1 ImmutableBag (org.eclipse.collections.api.bag.ImmutableBag)1 MutableBag (org.eclipse.collections.api.bag.MutableBag)1 ImmutableBooleanBag (org.eclipse.collections.api.bag.primitive.ImmutableBooleanBag)1 ImmutableByteBag (org.eclipse.collections.api.bag.primitive.ImmutableByteBag)1 ImmutableCharBag (org.eclipse.collections.api.bag.primitive.ImmutableCharBag)1 ImmutableDoubleBag (org.eclipse.collections.api.bag.primitive.ImmutableDoubleBag)1 ImmutableFloatBag (org.eclipse.collections.api.bag.primitive.ImmutableFloatBag)1 ImmutableIntBag (org.eclipse.collections.api.bag.primitive.ImmutableIntBag)1 ImmutableLongBag (org.eclipse.collections.api.bag.primitive.ImmutableLongBag)1 ImmutableShortBag (org.eclipse.collections.api.bag.primitive.ImmutableShortBag)1 MutableSortedBag (org.eclipse.collections.api.bag.sorted.MutableSortedBag)1