org.nuiton.math.matrix.MatrixIteratorImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nuiton-matrix Show documentation
Show all versions of nuiton-matrix Show documentation
Librairie de matrice multi-dimensions.
The newest version!
/* *##% NuitonMatrix
* Copyright (C) 2004 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* . ##%*/
package org.nuiton.math.matrix;
import java.util.List;
/**
* MatrixIteratorImpl.
*
* Created: 28 oct. 2004
*
* @author Benjamin Poussin
* @version $Revision: 187 $
*
* Mise a jour: $Date: 2009-10-16 19:17:29 +0200 (ven., 16 oct. 2009) $
* par : $Author: tchemit $
*/
public class MatrixIteratorImpl implements MatrixIterator { // MatrixIteratorImpl
protected BasicMatrixIterator iterator = null;
protected List>[] semantics = null;
protected int pos = 0;
/**
* @param iterator la matrice sur lequel l'iterator doit travailler
* @param semantics la semantique de matrix, si matrix n'a pas de semantique
* alors il faut passer null
*/
public MatrixIteratorImpl(BasicMatrixIterator iterator, List>[] semantics) {
this.iterator = iterator;
this.semantics = semantics;
pos = 0;
}
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public boolean next() {
return iterator.next();
}
@Override
public int[] getCoordinates() {
return iterator.getCoordinates();
}
@Override
public double getValue() {
return iterator.getValue();
}
@Override
public void setValue(double value) {
iterator.setValue(value);
}
@Override
public Object[] getSemanticsCoordinates() {
Object[] result = null;
if (semantics != null) {
int[] coordinates = getCoordinates();
result = MatrixHelper.dimensionToSemantics(semantics,
coordinates);
}
return result;
}
} // MatrixIteratorImpl