Search in sources :

Example 6 with ShortHashBag

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

the class MapIterateTest method collectShortWithTarget.

@Test
public void collectShortWithTarget() {
    ShortHashBag target = new ShortHashBag();
    MutableShortCollection result = MapIterate.collectShort(MapIterateTest.newLittleMap(), PrimitiveFunctions.unboxIntegerToShort(), target);
    Assert.assertEquals(ShortHashBag.newBagWith((short) 1, (short) 2), result.toBag());
    Assert.assertSame("Target sent as parameter was not returned as result", target, result);
}
Also used : MutableShortCollection(org.eclipse.collections.api.collection.primitive.MutableShortCollection) ShortHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag) Test(org.junit.Test)

Example 7 with ShortHashBag

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

the class MapIterableTestCase method collectShortWithTarget.

@Test
public void collectShortWithTarget() {
    ShortHashBag target = new ShortHashBag();
    MapIterable<String, String> map = this.newMapWithKeysValues("One", "1", "Two", "2", "Three", "3");
    ShortHashBag result = map.collectShort(Short::parseShort, target);
    Assert.assertSame("Target sent as parameter not returned", target, result);
    Assert.assertEquals(ShortHashBag.newBagWith((short) 1, (short) 2, (short) 3), result.toBag());
}
Also used : ShortHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag) Test(org.junit.Test)

Example 8 with ShortHashBag

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

the class ImmutableEmptySortedBagTest method collectShort_target.

@Override
@Test
public void collectShort_target() {
    ImmutableSortedBag<Integer> bag = this.classUnderTest();
    Assert.assertEquals(new ShortArrayList(), bag.collectShort(PrimitiveFunctions.unboxIntegerToShort(), new ShortArrayList()));
    ImmutableSortedBag<Integer> bag2 = this.classUnderTest();
    Assert.assertEquals(new ShortHashBag(), bag2.collectShort(PrimitiveFunctions.unboxIntegerToShort(), new ShortHashBag()));
}
Also used : ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) ShortHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag) Test(org.junit.Test)

Aggregations

ShortHashBag (org.eclipse.collections.impl.bag.mutable.primitive.ShortHashBag)8 Test (org.junit.Test)6 MutableShortBag (org.eclipse.collections.api.bag.primitive.MutableShortBag)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 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)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