Search in sources :

Example 6 with ByteHashBag

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

the class MapIterableTestCase method collectByteWithTarget.

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

Example 7 with ByteHashBag

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

the class ImmutableBagTestCase method collectByteWithTarget.

@Override
@Test
public void collectByteWithTarget() {
    super.collectByteWithTarget();
    ByteHashBag target = new ByteHashBag();
    ByteHashBag result = this.newBag().collectByte(Byte::parseByte, target);
    Assert.assertSame("Target sent as parameter not returned", target, result);
    Assert.assertEquals(this.numKeys(), result.sizeDistinct());
    for (int i = 1; i <= this.numKeys(); i++) {
        Assert.assertEquals(i, result.occurrencesOf((byte) i));
    }
}
Also used : ByteHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag) Test(org.junit.Test)

Example 8 with ByteHashBag

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

the class MapIterateTest method collectByteWithTarget.

@Test
public void collectByteWithTarget() {
    ByteHashBag target = new ByteHashBag();
    ByteHashBag result = MapIterate.collectByte(MapIterateTest.newLittleMap(), PrimitiveFunctions.unboxIntegerToByte(), target);
    Assert.assertEquals(ByteHashBag.newBagWith((byte) 1, (byte) 2), result.toBag());
    Assert.assertSame("Target sent as parameter was not returned as result", target, result);
}
Also used : ByteHashBag(org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag) Test(org.junit.Test)

Aggregations

ByteHashBag (org.eclipse.collections.impl.bag.mutable.primitive.ByteHashBag)8 Test (org.junit.Test)6 MutableByteBag (org.eclipse.collections.api.bag.primitive.MutableByteBag)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