Browse Source

[flash] provide Vector.insertAt for flash < 19

Dan Korostelev 6 years ago
parent
commit
026acc5202
1 changed files with 8 additions and 1 deletions
  1. 8 1
      std/flash/Vector.hx

+ 8 - 1
std/flash/Vector.hx

@@ -43,7 +43,14 @@ package flash;
 	function toString() : String;
 	function toString() : String;
 	function indexOf( x : T, ?from : Int ) : Int;
 	function indexOf( x : T, ?from : Int ) : Int;
 	function lastIndexOf( x : T, ?from : Int ) : Int;
 	function lastIndexOf( x : T, ?from : Int ) : Int;
-	@:require(flash19) function insertAt(index : Int, element : T) : Void;
+	
+	#if flash19
+	function insertAt(index : Int, element : T) : Void;
+	#else
+	inline function insertAt(index : Int, element: T) : Void {
+		(cast this).splice(index, 0, element);
+	}
+	#end
 	@:require(flash19) function removeAt(index:Int) : T;
 	@:require(flash19) function removeAt(index:Int) : T;
 
 
 	public inline static function ofArray<T>( v : Array<T> ) : Vector<T> {
 	public inline static function ofArray<T>( v : Array<T> ) : Vector<T> {