All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mikera.arrayz.impl.SliceElementIterator Maven / Gradle / Ivy

Go to download

Fast double-precision vector and matrix maths library for Java, supporting N-dimensional numeric arrays.

There is a newer version: 0.67.0
Show newest version
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