Array.indexOf() turns out to be there, just not documented.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4037 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -5,21 +5,6 @@ package com.threerings.util {
|
|||||||
*/
|
*/
|
||||||
public class ArrayUtil
|
public class ArrayUtil
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Return the first index of the specified element, or -1 if not present.
|
|
||||||
*/
|
|
||||||
public static function indexOf (arr :Array, element :Object) :int
|
|
||||||
{
|
|
||||||
// return mx.utils.ArrayUtil.getItemIndex(element, arr);
|
|
||||||
//
|
|
||||||
for (var ii :int = 0; ii < arr.length; ii++) {
|
|
||||||
if (arr[ii] === element) {
|
|
||||||
return ii;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the first instance of the specified element from the array.
|
* Remove the first instance of the specified element from the array.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class ObserverList
|
|||||||
*/
|
*/
|
||||||
public function add (observer :Object) :void
|
public function add (observer :Object) :void
|
||||||
{
|
{
|
||||||
if (ArrayUtil.indexOf(_list, observer) == -1) {
|
if (_list.indexOf(observer) == -1) {
|
||||||
_list.push(observer);
|
_list.push(observer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user