Search in sources :

Example 6 with IntHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag in project eclipse-collections by eclipse.

the class ImmutableEmptySortedBagTest method collectInt_target.

@Override
@Test
public void collectInt_target() {
    ImmutableSortedBag<Integer> bag = this.classUnderTest();
    Assert.assertEquals(new IntArrayList(), bag.collectInt(PrimitiveFunctions.unboxIntegerToInt(), new IntArrayList()));
    ImmutableSortedBag<Integer> bag2 = this.classUnderTest();
    Assert.assertEquals(new IntHashBag(), bag2.collectInt(PrimitiveFunctions.unboxIntegerToInt(), new IntHashBag()));
}
Also used : IntHashBag(org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) Test(org.junit.Test)

Example 7 with IntHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag in project eclipse-collections by eclipse.

the class MapIterableTestCase method collectIntWithTarget.

@Test
public void collectIntWithTarget() {
    IntHashBag target = new IntHashBag();
    MapIterable<String, String> map = this.newMapWithKeysValues("One", "1", "Two", "2", "Three", "3");
    IntHashBag result = map.collectInt(Integer::parseInt, target);
    Assert.assertSame("Target sent as parameter not returned", target, result);
    Assert.assertEquals(IntHashBag.newBagWith(1, 2, 3), result.toBag());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IntHashBag(org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag) Test(org.junit.Test)

Example 8 with IntHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag in project eclipse-collections by eclipse.

the class AbstractImmutableMap method collectInt.

@Override
public ImmutableIntBag collectInt(IntFunction<? super V> intFunction) {
    MutableIntBag result = new IntHashBag();
    this.forEach(new CollectIntProcedure<>(intFunction, result));
    return result.toImmutable();
}
Also used : MutableIntBag(org.eclipse.collections.api.bag.primitive.MutableIntBag) IntHashBag(org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag)

Example 9 with IntHashBag

use of org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag in project eclipse-collections by eclipse.

the class AbstractRichIterableTestCase method collectIntWithBagTarget.

@Test
public void collectIntWithBagTarget() {
    IntHashBag target = new IntHashBag();
    IntHashBag result = this.newWith(1, 2, 3, 4).collectInt(PrimitiveFunctions.unboxIntegerToInt(), target);
    Assert.assertSame("Target list sent as parameter not returned", target, result);
    Assert.assertEquals(IntHashBag.newBagWith(1, 2, 3, 4), result);
}
Also used : IntHashBag(org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag) Test(org.junit.Test)

Aggregations

IntHashBag (org.eclipse.collections.impl.bag.mutable.primitive.IntHashBag)9 Test (org.junit.Test)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 MutableIntBag (org.eclipse.collections.api.bag.primitive.MutableIntBag)2 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 BooleanIterable (org.eclipse.collections.api.BooleanIterable)1 ByteIterable (org.eclipse.collections.api.ByteIterable)1 CharIterable (org.eclipse.collections.api.CharIterable)1 DoubleIterable (org.eclipse.collections.api.DoubleIterable)1 FloatIterable (org.eclipse.collections.api.FloatIterable)1 IntIterable (org.eclipse.collections.api.IntIterable)1 LongIterable (org.eclipse.collections.api.LongIterable)1 RichIterable (org.eclipse.collections.api.RichIterable)1 ShortIterable (org.eclipse.collections.api.ShortIterable)1