package org.kevoree.modeling.memory.space.impl;

import org.kevoree.modeling.memory.KChunk;
import org.kevoree.modeling.memory.space.KChunkIterator;
import org.kevoree.modeling.memory.space.KChunkSpace;

public class ChunkIterator implements KChunkIterator {

    private final long[] _dirties;
    private final KChunkSpace _origin;

    private int currentIndex = 0;
    private int maxIndex = 0;

    public ChunkIterator(long[] p_dirties, KChunkSpace p_origin) {
        this._dirties = p_dirties;
        this._origin = p_origin;
        maxIndex = p_dirties.length / 3;
    }

    @Override
    public boolean hasNext() {
        return currentIndex < maxIndex;
    }

    @Override
    public KChunk next() {
        KChunk current = null;
        if (currentIndex < maxIndex) {
            current = _origin.get(_dirties[currentIndex], _dirties[currentIndex + 1], _dirties[currentIndex + 2]);
        }
        this.currentIndex = this.currentIndex + 3;
        return current;
    }

    @Override
    public int size() {
        return this.maxIndex;
    }
}

@@ -834,16 +834,18 @@
 entIndex
+*3
 %5D, _dirt
@@ -860,16 +860,18 @@
 entIndex
+*3
  + 1%5D, _
@@ -890,16 +890,18 @@
 entIndex
+*3
  + 2%5D);%0A
@@ -939,32 +939,10 @@
 ndex
- = this.currentIndex + 3
+++
 ;%0A  

fix chunk iterator