me.shaftesbury.utils.functional.ArrayIterable Maven / Gradle / Ivy
package me.shaftesbury.utils.functional;
/**
* Created with IntelliJ IDEA.
* User: Bob
* Date: 31/10/13
* Time: 09:14
* To change this template use File | Settings | File Templates.
*/
import java.util.Iterator;
public final class ArrayIterable implements Iterable
{
private final T[] _a;
private ArrayIterable(final T[] array) { _a = array; }
public final Iterator iterator()
{
return new Iterator()
{
private final T[] _array = _a;
private int _posn = 0;
public final boolean hasNext() { return _posn < _array.length; }
public final T next() { return _array[_posn++]; }
public void remove() { throw new UnsupportedOperationException("remove is not permitted in ArrayIterable"); }
};
}
public final static ArrayIterable create(final T[] array) { return new ArrayIterable(array); }
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy