use of org.eclipse.collections.impl.list.mutable.primitive.CharArrayList in project eclipse-collections by eclipse.
the class AbstractRichIterableTestCase method collectCharWithTarget.
@Test
public void collectCharWithTarget() {
MutableCharCollection target = new CharArrayList();
CharIterable result = this.newWith(1, 2, 3, 4).collectChar(PrimitiveFunctions.unboxIntegerToChar(), target);
Assert.assertSame("Target list sent as parameter not returned", target, result);
Assert.assertEquals(CharHashBag.newBagWith((char) 1, (char) 2, (char) 3, (char) 4), result.toBag());
}
use of org.eclipse.collections.impl.list.mutable.primitive.CharArrayList in project eclipse-collections by eclipse.
the class ArrayIterateTest method collectCharWithTarget.
@Test
public void collectCharWithTarget() {
Integer[] objectArray = { -1, 0, 42 };
CharArrayList target = new CharArrayList();
CharArrayList result = ArrayIterate.collectChar(objectArray, PrimitiveFunctions.unboxIntegerToChar(), target);
Assert.assertEquals(this.getExpectedCharResults(), result);
Assert.assertSame("Target List not returned as result", target, result);
}
use of org.eclipse.collections.impl.list.mutable.primitive.CharArrayList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectCharWithTargetOverOptimizeLimit.
@Test
public void collectCharWithTargetOverOptimizeLimit() {
ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
MutableCharList target = new CharArrayList();
MutableCharList actual = ArrayListIterate.collectChar(list, PrimitiveFunctions.unboxIntegerToChar(), target);
CharArrayList expected = new CharArrayList(list.size());
for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
expected.add((char) i);
}
Assert.assertEquals(expected, actual);
Assert.assertSame("Target sent as parameter was not returned as result", target, actual);
}
use of org.eclipse.collections.impl.list.mutable.primitive.CharArrayList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectCharWithTarget.
@Test
public void collectCharWithTarget() {
ArrayList<Integer> list = this.createIntegerList();
MutableCharList target = new CharArrayList();
MutableCharList actual = ArrayListIterate.collectChar(list, PrimitiveFunctions.unboxIntegerToChar(), target);
Assert.assertSame("Target list sent as parameter not returned", target, actual);
Assert.assertEquals(CharArrayList.newListWith((char) -1, (char) 0, (char) 4), actual);
}
use of org.eclipse.collections.impl.list.mutable.primitive.CharArrayList in project eclipse-collections by eclipse.
the class AbstractImmutableList method collectChar.
@Override
public ImmutableCharList collectChar(CharFunction<? super T> charFunction) {
CharArrayList result = new CharArrayList(this.size());
this.forEach(new CollectCharProcedure<>(charFunction, result));
return result.toImmutable();
}
Aggregations