Search in sources :

Example 1 with MutableIntList

use of org.eclipse.collections.api.list.primitive.MutableIntList in project eclipse-collections by eclipse.

the class CodePointAdapter method newWithoutAll.

@Override
public CodePointAdapter newWithoutAll(IntIterable elements) {
    MutableIntList mutableIntList = this.toList();
    mutableIntList.removeAll(elements);
    return CodePointAdapter.from(mutableIntList.toArray());
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList)

Example 2 with MutableIntList

use of org.eclipse.collections.api.list.primitive.MutableIntList in project eclipse-collections by eclipse.

the class IntInterval method chunk.

@Override
public RichIterable<IntIterable> chunk(int size) {
    if (size <= 0) {
        throw new IllegalArgumentException("Size for groups must be positive but was: " + size);
    }
    MutableList<IntIterable> result = Lists.mutable.empty();
    if (this.notEmpty()) {
        int innerFrom = this.from;
        int lastUpdated = this.from;
        if (this.from <= this.to) {
            while ((lastUpdated + this.step) <= this.to) {
                MutableIntList batch = IntLists.mutable.empty();
                for (int i = innerFrom; i <= this.to && batch.size() < size; i += this.step) {
                    batch.add(i);
                    lastUpdated = i;
                }
                result.add(batch);
                innerFrom = lastUpdated + this.step;
            }
        } else {
            while ((lastUpdated + this.step) >= this.to) {
                MutableIntList batch = IntLists.mutable.empty();
                for (int i = innerFrom; i >= this.to && batch.size() < size; i += this.step) {
                    batch.add(i);
                    lastUpdated = i;
                }
                result.add(batch);
                innerFrom = lastUpdated + this.step;
            }
        }
    }
    return result;
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) IntIterable(org.eclipse.collections.api.IntIterable) SelectIntIterable(org.eclipse.collections.impl.lazy.primitive.SelectIntIterable) ReverseIntIterable(org.eclipse.collections.impl.lazy.primitive.ReverseIntIterable) LazyIntIterable(org.eclipse.collections.api.LazyIntIterable)

Example 3 with MutableIntList

use of org.eclipse.collections.api.list.primitive.MutableIntList in project eclipse-collections by eclipse.

the class ArrayListIterateTest method collectInt.

@Test
public void collectInt() {
    ArrayList<Integer> list = this.createIntegerList();
    MutableIntList actual = ArrayListIterate.collectInt(list, PrimitiveFunctions.unboxIntegerToInt());
    Assert.assertEquals(IntArrayList.newListWith(-1, 0, 4), actual);
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) Test(org.junit.Test)

Example 4 with MutableIntList

use of org.eclipse.collections.api.list.primitive.MutableIntList 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);
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) IntArrayList(org.eclipse.collections.impl.list.mutable.primitive.IntArrayList) Test(org.junit.Test)

Example 5 with MutableIntList

use of org.eclipse.collections.api.list.primitive.MutableIntList in project eclipse-collections by eclipse.

the class PrimitiveStreamsTest method toIntList.

@Test
public void toIntList() {
    MutableIntList list = PrimitiveStreams.mIntList(IntStream.rangeClosed(1, 10));
    Assert.assertEquals(IntInterval.oneTo(10), list);
    Assert.assertEquals(IntLists.immutable.ofAll(IntStream.rangeClosed(1, 10)), list);
}
Also used : MutableIntList(org.eclipse.collections.api.list.primitive.MutableIntList) Test(org.junit.Test)

Aggregations

MutableIntList (org.eclipse.collections.api.list.primitive.MutableIntList)19 IntArrayList (org.eclipse.collections.impl.list.mutable.primitive.IntArrayList)8 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)2 IntIterable (org.eclipse.collections.api.IntIterable)2 LazyIntIterable (org.eclipse.collections.api.LazyIntIterable)2 IntIterator (org.eclipse.collections.api.iterator.IntIterator)2 ReverseIntIterable (org.eclipse.collections.impl.lazy.primitive.ReverseIntIterable)2 BooleanArrayList (org.eclipse.collections.impl.list.mutable.primitive.BooleanArrayList)2 ByteArrayList (org.eclipse.collections.impl.list.mutable.primitive.ByteArrayList)2 CharArrayList (org.eclipse.collections.impl.list.mutable.primitive.CharArrayList)2 DoubleArrayList (org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList)2 FloatArrayList (org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList)2 LongArrayList (org.eclipse.collections.impl.list.mutable.primitive.LongArrayList)2 ShortArrayList (org.eclipse.collections.impl.list.mutable.primitive.ShortArrayList)2 MutableLong (org.apache.commons.lang3.mutable.MutableLong)1 SelectIntIterable (org.eclipse.collections.impl.lazy.primitive.SelectIntIterable)1 AbstractIntIterable (org.eclipse.collections.impl.primitive.AbstractIntIterable)1 Test (org.junit.jupiter.api.Test)1 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)1