package org.kevoree.modeling.util.maths.structure.impl;

import org.kevoree.modeling.memory.struct.segment.KMemorySegment;
import org.kevoree.modeling.meta.KMetaClass;
import org.kevoree.modeling.util.maths.structure.KArray3D;

public class Array3D implements KArray3D {

    private int _nbRaws;

    private int _nbColumns;

    private int _nbDeeps;

    private int _offset;

    private int _segmentIndex;

    private KMemorySegment _segment;

    private KMetaClass _metaClass;

    public Array3D(int p_nbRaws, int p_nbColumns, int p_nbDeeps, int p_offset, int p_segmentIndex, KMemorySegment p_segment, KMetaClass p_metaClass) {
        this._nbRaws = p_nbRaws;
        this._nbColumns = p_nbColumns;
        this._nbDeeps = p_nbDeeps;
        this._offset = p_offset;
        this._segmentIndex = p_segmentIndex;
        this._segment = p_segment;
        this._metaClass = p_metaClass;
    }

    @Override
    public int nbRaws() {
        return this._nbRaws;
    }

    @Override
    public int nbColumns() {
        return this._nbColumns;
    }

    @Override
    public int nbDeeps() {
        return this._nbDeeps;
    }

    @Override
    public double get(int p_rawIndex, int p_columnIndex, int p_deepIndex) {
        return this._segment.getInferElem(this._segmentIndex, this._offset + (p_rawIndex * this._nbColumns * this._nbDeeps) + p_columnIndex + p_deepIndex, this._metaClass);
    }

    @Override
    public double set(int p_rawIndex, int p_columnIndex, int p_deepIndex, double p_value) {
        this._segment.setInferElem(this._segmentIndex, this._offset + (p_rawIndex * this._nbColumns * this._nbDeeps) + p_columnIndex + p_deepIndex, p_value, this._metaClass);
        return p_value;
    }

    @Override
    public double add(int p_rawIndex, int p_columnIndex, int p_deepIndex, double value) {
        return set(p_rawIndex,p_columnIndex,p_deepIndex,get(p_rawIndex,p_columnIndex,p_deepIndex)+value);
    }
}

@@ -1294,35 +1294,36 @@
 is._offset + (p_
-raw
+deep
 Index * this._nb
@@ -1332,36 +1332,35 @@
 lumns * this._nb
-Deep
+Raw
 s) + p_columnInd
@@ -1357,33 +1357,47 @@
 _columnIndex
+* this._nbRaws 
  + p_
-deep
+raw
 Index, this.
@@ -1595,19 +1595,20 @@
 et + (p_
-raw
+deep
 Index * 
@@ -1633,20 +1633,19 @@
 this._nb
-Deep
+Raw
 s) + p_c
@@ -1658,17 +1658,31 @@
 ndex
+* this._nbRaws 
  + p_
-deep
+raw
 Inde

fix array3d