use of org.eclipse.collections.api.iterator.IntIterator in project eclipse-collections by eclipse.
the class CodePointAdapter 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()) {
if (this.size() <= size) {
result.add(IntLists.immutable.withAll(this));
} else {
IntIterator iterator = this.intIterator();
while (iterator.hasNext()) {
MutableIntList batch = IntLists.mutable.empty();
for (int i = 0; i < size && iterator.hasNext(); i++) {
batch.add(iterator.next());
}
result.add(CodePointList.from(batch));
}
}
}
return result.toImmutable();
}
use of org.eclipse.collections.api.iterator.IntIterator in project eclipse-collections by eclipse.
the class CodePointAdapter method zipInt.
/**
* @since 9.1.
*/
@Override
public ImmutableList<IntIntPair> zipInt(IntIterable iterable) {
int size = this.size();
int othersize = iterable.size();
MutableList<IntIntPair> target = Lists.mutable.withInitialCapacity(Math.min(size, othersize));
IntIterator iterator = iterable.intIterator();
for (int i = 0; i < size && i < othersize; i++) {
target.add(PrimitiveTuples.pair(this.get(i), iterator.next()));
}
return target.toImmutable();
}
use of org.eclipse.collections.api.iterator.IntIterator in project eclipse-collections by eclipse.
the class CodePointList method zipInt.
/**
* @since 9.1.
*/
@Override
public ImmutableList<IntIntPair> zipInt(IntIterable iterable) {
int size = this.size();
int othersize = iterable.size();
MutableList<IntIntPair> target = Lists.mutable.withInitialCapacity(Math.min(size, othersize));
IntIterator iterator = iterable.intIterator();
for (int i = 0; i < size && i < othersize; i++) {
target.add(PrimitiveTuples.pair(this.get(i), iterator.next()));
}
return target.toImmutable();
}
use of org.eclipse.collections.api.iterator.IntIterator in project eclipse-collections by eclipse.
the class IntIntervalTest method iterator.
@Test
public void iterator() {
IntIterator iterator = this.intInterval.intIterator();
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals(1L, iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals(2L, iterator.next());
Assert.assertTrue(iterator.hasNext());
Assert.assertEquals(3L, iterator.next());
Assert.assertFalse(iterator.hasNext());
}
use of org.eclipse.collections.api.iterator.IntIterator in project eclipse-collections by eclipse.
the class IntInterval method zipInt.
@Override
public ImmutableList<IntIntPair> zipInt(IntIterable iterable) {
int size = this.size();
int othersize = iterable.size();
MutableList<IntIntPair> target = Lists.mutable.withInitialCapacity(Math.min(size, othersize));
IntIterator iterator = this.intIterator();
IntIterator otherIterator = iterable.intIterator();
for (int i = 0; i < size && otherIterator.hasNext(); i++) {
target.add(PrimitiveTuples.pair(iterator.next(), otherIterator.next()));
}
return target.toImmutable();
}
Aggregations