use of org.eclipse.collections.api.iterator.CharIterator 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.iterator.CharIterator in project eclipse-collections by eclipse.
the class CharAdapter method zipChar.
/**
* @since 9.1.
*/
@Override
public ImmutableList<CharCharPair> zipChar(CharIterable iterable) {
int size = this.size();
int othersize = iterable.size();
MutableList<CharCharPair> target = Lists.mutable.withInitialCapacity(Math.min(size, othersize));
CharIterator iterator = iterable.charIterator();
for (int i = 0; i < size && i < othersize; i++) {
target.add(PrimitiveTuples.pair(this.get(i), iterator.next()));
}
return target.toImmutable();
}
Aggregations