net.lakis.cerebro.collections.loop.CustomIntegerArrayLoop Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cerebro Show documentation
Show all versions of cerebro Show documentation
A framework to handle dependency injection and allowing users to communicate with the application
using command line.
The newest version!
package net.lakis.cerebro.collections.loop;
import java.util.Iterator;
public class CustomIntegerArrayLoop implements Iterable {
private int idx;
private int size;
private int[] array;
private int start;
public CustomIntegerArrayLoop(int[] array, int start) {
this.idx = 0;
this.array = array;
if (array != null)
this.size = array.length;
if (size > 0)
this.start = (start & 0x7FFFFFFF) % size;
}
@Override
public Iterator iterator() {
return new Iterator() {
@Override
public boolean hasNext() {
return idx < size;
}
@Override
public Integer next() {
return array[(start + idx++) % size];
}
};
}
}