Some fixups and enhancements.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4294 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-07-28 02:48:52 +00:00
parent ad74efc332
commit 7c17069a16
4 changed files with 69 additions and 8 deletions
+17 -1
View File
@@ -1,7 +1,11 @@
package com.threerings.util {
/**
* Contains methods that should be in Array, but aren't.
* Contains methods that should be in Array, but aren't. Additionally
* contains methods that understand the interfaces in this package.
* So, for example, removeFirst() understands Equalable and will remove
* an element that is equals() to the specified element, rather than just
* ===.
*/
public class ArrayUtil
{
@@ -24,6 +28,18 @@ public class ArrayUtil
});
}
public static function indexOf (arr :Array, element :Object) :int
{
if (arr != null) {
for (var ii :int = 0; ii < arr.length; ii++) {
if (Util.equals(arr[ii], element)) {
return ii;
}
}
}
return -1; // never found
}
/**
* Remove the first instance of the specified element from the array.
*/