Broke out array equals() into its own method.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4661 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2007-04-14 02:59:51 +00:00
parent 773e53ec2d
commit 20e9eb66bd
2 changed files with 21 additions and 11 deletions
+20
View File
@@ -107,6 +107,26 @@ public class ArrayUtil
return removeImpl(arr, element, false); return removeImpl(arr, element, false);
} }
/**
* Do the two arrays contain elements that are all equals()?
*/
public static function equals (ar1 :Array, ar2 :Array) :Boolean
{
if (ar1 === ar2) {
return true;
} else if (ar1 == null || ar2 == null || ar1.length != ar2.length) {
return false;
}
for (var jj :int = 0; jj < ar1.length; jj++) {
if (!Util.equals(ar1[jj], ar2[jj])) {
return false;
}
}
return true;
}
/** /**
* Implementation of remove methods. * Implementation of remove methods.
*/ */
+1 -11
View File
@@ -64,17 +64,7 @@ public class Util
return (obj1 as Equalable).equals(obj2); return (obj1 as Equalable).equals(obj2);
} else if ((obj1 is Array) && (obj2 is Array)) { } else if ((obj1 is Array) && (obj2 is Array)) {
var ar1 :Array = (obj1 as Array); return ArrayUtil.equals(obj1 as Array, obj2 as Array);
var ar2 :Array = (obj2 as Array);
if (ar1.length != ar2.length) {
return false;
}
for (var jj :int = 0; jj < ar1.length; jj++) {
if (!equals(ar1[jj], ar2[jj])) {
return false;
}
}
return true;
} else if ((obj1 is ByteArray) && (obj2 is ByteArray)) { } else if ((obj1 is ByteArray) && (obj2 is ByteArray)) {
var ba1 :ByteArray = (obj1 as ByteArray); var ba1 :ByteArray = (obj1 as ByteArray);