xapi.collect.impl.ArrayIterable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xapi-dev Show documentation
Show all versions of xapi-dev Show documentation
Everything needed to run a comprehensive dev environment.
Just type X_ and pick a service from autocomplete;
new dev modules will be added as they are built.
The only dev service not included in the uber jar is xapi-dev-maven,
as it includes all runtime dependencies of maven, adding ~4 seconds to build time,
and 6 megabytes to the final output jar size (without xapi-dev-maven, it's ~1MB).
The newest version!
package xapi.collect.impl;
import java.util.Iterator;
import xapi.except.NotImplemented;
public class ArrayIterable implements Iterable {
private final E[] array;
private final class Itr implements Iterator {
int pos = 0, end = array.length;
@Override
public boolean hasNext() {
return pos < end;
}
@Override
public E next() {
return array[pos++];
}
@Override
public void remove() {
ArrayIterable.this.remove(array[pos-1]);
}
}
public ArrayIterable(E[] array) {
this.array = array;
}
@Override
public Iterator iterator() {
return new Itr();
}
protected void remove(E key) {
throw new NotImplemented("ArrayIterable does not support remove");
}
}