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

import org.kevoree.modeling.memory.chunk.KObjectChunk;
import org.kevoree.modeling.meta.KMetaClass;
import org.kevoree.modeling.util.maths.structure.KArray2D;

public class NativeArray2D implements KArray2D {

    private int _nbRows;

    private int _nbColumns;

    private int _offset;

    private int _segmentIndex;

    private KObjectChunk _segment;

    private KMetaClass _metaClass;

    public NativeArray2D(int p_nbRows, int p_nbColumns, int p_offset, int p_segmentIndex, KObjectChunk p_segment, KMetaClass p_metaClass) {
        this._nbRows = p_nbRows;
        this._nbColumns = p_nbColumns;
        this._offset = p_offset;
        this._segment = p_segment;
        this._segmentIndex = p_segmentIndex;
        this._metaClass = p_metaClass;
    }

    @Override
    public int nbRows() {
        return this._nbRows;
    }

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

    @Override
    public double get(int p_rowIndex, int p_columnIndex) {
        return this._segment.getDoubleArrayElem(this._segmentIndex, this._offset + (p_rowIndex * this._nbColumns) + p_columnIndex, this._metaClass);
    }

    @Override
    public double set(int p_rowIndex, int p_columnIndex, double value) {
        this._segment.setDoubleArrayElem(this._segmentIndex, this._offset + (p_rowIndex * this._nbColumns) + p_columnIndex, value, this._metaClass);
        return value;
    }

    @Override
    public double add(int rawIndex, int columnIndex, double value) {
        return set(rawIndex,columnIndex,get(rawIndex,columnIndex)+value);
    }
}

@@ -54,108 +54,8 @@
 l;%0A%0A
-import org.kevoree.modeling.memory.chunk.KObjectChunk;%0Aimport org.kevoree.modeling.meta.KMetaClass;%0A
 impo
@@ -257,97 +257,22 @@
 ate 
-int _segmentIndex;%0A%0A    private KObjectChunk _segment;%0A%0A    private KMetaClass _metaClass
+double%5B%5D _back
 ;%0A%0A 
@@ -344,74 +344,23 @@
 et, 
-int p_segmentIndex, KObjectChunk p_segment, KMetaClass p_metaClass
+double%5B%5D p_back
 ) %7B%0A
@@ -482,111 +482,21 @@
 is._
-segment = p_segment;%0A        this._segmentIndex = p_segmentIndex;%0A        this._metaClass = p_metaClass
+back = p_back
 ;%0A  
@@ -756,55 +756,13 @@
 is._
-segment.getDoubleArrayElem(this._segmentIndex, 
+back%5B
 this
@@ -818,34 +818,17 @@
 umnIndex
-, this._metaClass)
+%5D
 ;%0A    %7D%0A
@@ -933,55 +933,13 @@
 is._
-segment.setDoubleArrayElem(this._segmentIndex, 
+back%5B
 this
@@ -999,33 +999,17 @@
 ndex
-,
+%5D =
  value
-, this._metaClass)
 ;%0A  
@@ -1138,32 +1138,33 @@
 rn set(rawIndex,
+ 
 columnIndex,get(
@@ -1159,16 +1159,17 @@
 mnIndex,
+ 
 get(rawI
@@ -1173,16 +1173,17 @@
 awIndex,
+ 
 columnIn
@@ -1186,17 +1186,19 @@
 mnIndex)
-+
+ + 
 value);%0A

add native array 2D