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:
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user