use of org.eclipse.collections.api.list.primitive.MutableCharList in project eclipse-collections by eclipse.
the class ArrayListIterateTest method collectCharOverOptimizeLimit.
@Test
public void collectCharOverOptimizeLimit() {
ArrayList<Integer> list = new ArrayList<>(Interval.zeroTo(OVER_OPTIMIZED_LIMIT));
MutableCharList actual = ArrayListIterate.collectChar(list, PrimitiveFunctions.unboxIntegerToChar());
CharArrayList expected = new CharArrayList(list.size());
for (int i = 0; i <= OVER_OPTIMIZED_LIMIT; i++) {
expected.add((char) i);
}
Assert.assertEquals(expected, actual);
}
use of org.eclipse.collections.api.list.primitive.MutableCharList in project eclipse-collections by eclipse.
the class CharAdapter method chunk.
@Override
public RichIterable<CharIterable> chunk(int size) {
if (size <= 0) {
throw new IllegalArgumentException("Size for groups must be positive but was: " + size);
}
MutableList<CharIterable> result = Lists.mutable.empty();
if (this.notEmpty()) {
CharIterator iterator = this.charIterator();
while (iterator.hasNext()) {
MutableCharList batch = CharLists.mutable.empty();
for (int i = 0; i < size && iterator.hasNext(); i++) {
batch.add(iterator.next());
}
result.add(batch);
}
}
return result;
}
use of org.eclipse.collections.api.list.primitive.MutableCharList in project eclipse-collections by eclipse.
the class AbstractListTestCase method collectChar.
@Override
public void collectChar() {
super.collectChar();
MutableCharList result = this.newWith(1, 2, 3, 4).collectChar(PrimitiveFunctions.unboxIntegerToChar());
Assert.assertEquals(CharLists.mutable.of((char) 1, (char) 2, (char) 3, (char) 4), result);
}
Aggregations