mikera.arrayz.impl.SliceElementIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vectorz Show documentation
Show all versions of vectorz Show documentation
Fast double-precision vector and matrix maths library for Java, supporting N-dimensional numeric arrays.
package mikera.arrayz.impl;
import java.util.Iterator;
import mikera.arrayz.INDArray;
/**
* General purpose iterator for elements of arbitrary arrays.
*
* @author Mike
*/
public class SliceElementIterator implements Iterator {
private final INDArray source;
private final int maxPos;
private int pos;
private Iterator inner;
public SliceElementIterator(INDArray source) {
this.pos=0;
this.source=source;
this.maxPos=source.sliceCount();
inner=source.slice(pos).elementIterator();
if (!inner.hasNext()) {
pos=maxPos;
}
}
public SliceElementIterator(INDArray source, int start, int length) {
this.pos=start;
this.source=source;
this.maxPos=start+length;
}
@Override
public boolean hasNext() {
return (pos
© 2015 - 2025 Weber Informatics LLC | Privacy Policy