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:
@@ -144,6 +144,19 @@ public class ArrayUtil
|
|||||||
return true;
|
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.
|
* Implementation of remove methods.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user