Possible Haxe implementation of Java's System.arraycopy?

Hello,

I am working on a port of Java library to Haxe. There are some Java standard library that is not available on Haxe. The one I actually need is System.arraycopy

here’s my attempt, but I don’t trust it!

class System {
    public static function arraycopy(source_array:Array<T>, source_pos:Int, dest_array:Array<T>, dest_pos:Int, len:Int) {
        var newV = this.source_array.splice(source_pos, len);
		var k = 0;
    	for(i in source_pos...len)
			while(k < n)
            	dest_array[k+dest_pos] = newV[i];
				break;
			k++;
   }

}

Can anyone suggest a better way to achieve this?

You can borrow the implementation from haxe.ds.Vector.blit() (note that it doesn’t do any bounds checking).

Thank you very much. This is helpful.