diff --git a/src/as/com/threerings/util/ArrayUtil.as b/src/as/com/threerings/util/ArrayUtil.as index 3b36141c2..96efd4f5e 100644 --- a/src/as/com/threerings/util/ArrayUtil.as +++ b/src/as/com/threerings/util/ArrayUtil.as @@ -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. */