30 lines
		
	
	
		
			667 B
		
	
	
	
		
			Haxe
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			667 B
		
	
	
	
		
			Haxe
		
	
	
	
	
	
package kha.arrays;
 | 
						|
 | 
						|
@:forward
 | 
						|
abstract Float64Array(ByteArray) from ByteArray to ByteArray {
 | 
						|
	public var length(get, never): Int;
 | 
						|
 | 
						|
	inline function get_length(): Int {
 | 
						|
		return this.byteLength >> 3;
 | 
						|
	}
 | 
						|
 | 
						|
	public function new(elements: Int) {
 | 
						|
		this = ByteArray.make(elements * 8);
 | 
						|
	}
 | 
						|
 | 
						|
	@:arrayAccess
 | 
						|
	public inline function get(k: Int): Float {
 | 
						|
		return this.getFloat64(k * 8);
 | 
						|
	}
 | 
						|
 | 
						|
	@:arrayAccess
 | 
						|
	public inline function set(k: Int, v: Float): Float {
 | 
						|
		this.setFloat64(k * 8, v);
 | 
						|
		return v;
 | 
						|
	}
 | 
						|
 | 
						|
	public inline function subarray(start: Int, ?end: Int): Float64Array {
 | 
						|
		return this.subarray(start * 8, end != null ? end * 8 : end);
 | 
						|
	}
 | 
						|
}
 |