use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList in project eclipse-collections by eclipse.
the class AbstractLazyIterableTestCase method collectIntWithTarget.
@Test
public void collectIntWithTarget() {
MutableIntCollection target = new IntArrayList();
MutableIntCollection result = this.lazyIterable.collectInt(PrimitiveFunctions.unboxIntegerToInt(), target);
Assert.assertEquals(IntArrayList.newListWith(1, 2, 3, 4, 5, 6, 7), result.toList());
Assert.assertSame("Target list sent as parameter not returned", target, result);
}
use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList in project eclipse-collections by eclipse.
the class AbstractImmutableSortedMap method collectInt.
@Override
public ImmutableIntList collectInt(IntFunction<? super V> intFunction) {
IntArrayList result = new IntArrayList(this.size());
this.forEach(new CollectIntProcedure<>(intFunction, result));
return result.toImmutable();
}
use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList in project eclipse-collections by eclipse.
the class RandomAccessListAdapter method collectInt.
@Override
public MutableIntList collectInt(IntFunction<? super T> intFunction) {
IntArrayList result = new IntArrayList(this.size());
this.forEach(new CollectIntProcedure<>(intFunction, result));
return result;
}
use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectIntWithTarget.
@Test
public void collectIntWithTarget() {
ArrayList<Integer> list = this.createIntegerList();
MutableIntList target = new IntArrayList();
MutableIntList actual = ArrayListIterate.collectInt(list, PrimitiveFunctions.unboxIntegerToInt(), target);
Assert.assertSame("Target list sent as parameter not returned", target, actual);
Assert.assertEquals(IntArrayList.newListWith(-1, 0, 4), actual);
}
use of org.eclipse.collections.impl.list.mutable.primitive.IntArrayList in project eclipse-collections by eclipse.
the class IterateTest method collectIntWithTarget.
@Test
public void collectIntWithTarget() {
this.iterables.each(each -> {
MutableIntCollection expected = new IntArrayList();
MutableIntCollection actual = Iterate.collectInt(each, PrimitiveFunctions.unboxIntegerToInt(), expected);
Assert.assertTrue(actual.containsAll(1, 2, 3, 4, 5));
Assert.assertSame("Target list sent as parameter not returned", expected, actual);
});
Verify.assertThrows(IllegalArgumentException.class, () -> Iterate.collectInt(null, PrimitiveFunctions.unboxIntegerToInt(), new IntArrayList()));
}
Aggregations