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());
}
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;
}
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);
}
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);
}
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);
}
Aggregations