Search in sources :

Example 6 with MutableCharList

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);
}
Also used : MutableCharList(org.eclipse.collections.api.list.primitive.MutableCharList) CharArrayList(org.eclipse.collections.impl.list.mutable.primitive.CharArrayList) DoubleArrayList(org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList) ShortArrayList(org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) ByteArrayList(org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList) CharArrayList(org.eclipse.collections.impl.list.mutable.primitive.CharArrayList) FloatArrayList(org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList) LongArrayList(org.eclipse.collections.impl.list.mutable.primitive.LongArrayList) ArrayList(java.util.ArrayList) BooleanArrayList(org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList) Test(org.junit.Test)

Example 7 with MutableCharList

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;
}
Also used : MutableCharList(org.eclipse.collections.api.list.primitive.MutableCharList) LazyCharIterable(org.eclipse.collections.api.LazyCharIterable) ReverseCharIterable(org.eclipse.collections.impl.lazy.primitive.ReverseCharIterable) CharIterable(org.eclipse.collections.api.CharIterable) AbstractCharIterable(org.eclipse.collections.impl.primitive.AbstractCharIterable) CharIterator(org.eclipse.collections.api.iterator.CharIterator)

Example 8 with MutableCharList

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);
}
Also used : MutableCharList(org.eclipse.collections.api.list.primitive.MutableCharList)

Aggregations

MutableCharList (org.eclipse.collections.api.list.primitive.MutableCharList)8 Test (org.junit.Test)4 CharArrayList (org.eclipse.collections.impl.list.mutable.primitive.CharArrayList)3 ArrayList (java.util.ArrayList)2 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)2 ByteArrayList (org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)2 DoubleArrayList (org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList)2 FloatArrayList (org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList)2 IntArrayList (org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)2 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)2 ShortArrayList (org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)2 CharIterable (org.eclipse.collections.api.CharIterable)1 LazyCharIterable (org.eclipse.collections.api.LazyCharIterable)1 CharIterator (org.eclipse.collections.api.iterator.CharIterator)1 ReverseCharIterable (org.eclipse.collections.impl.lazy.primitive.ReverseCharIterable)1 AbstractCharIterable (org.eclipse.collections.impl.primitive.AbstractCharIterable)1