added an insert method

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4887 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Nathan Curtis
2007-11-30 01:54:51 +00:00
parent be0eaf6a22
commit 9ddea518fc
+13
View File
@@ -144,6 +144,19 @@ public class ArrayUtil
return true;
}
/**
* Inserts the element into the array at the given index, increasing the index on all
* remaining elements by one. This function modifies the array passed in, rather than creating
* a new one.
*/
public static function insert (arr :Array, index :int, element :Object) :void
{
for (var ii :int = arr.length; ii > index; ii--) {
arr[ii] = arr[ii - 1];
}
arr[index] = element;
}
/**
* Implementation of remove methods.
*/