git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4296 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-07-29 01:10:15 +00:00
parent 3d7c12a5d1
commit 47a8a27a4e
4 changed files with 36 additions and 57 deletions
+5 -22
View File
@@ -6,6 +6,7 @@ import com.threerings.util.ArrayIterator;
import com.threerings.util.Equalable;
import com.threerings.util.Iterator;
import com.threerings.util.StringBuilder;
import com.threerings.util.Util;
import com.threerings.io.ObjectInputStream;
import com.threerings.io.ObjectOutputStream;
@@ -70,7 +71,7 @@ public class DSet
{
// o(n) for now
for each (var entry :DSet_Entry in _entries) {
if (isSameKey(key, entry.getKey())) {
if (Util.equals(key, entry.getKey())) {
return entry;
}
}
@@ -157,7 +158,7 @@ public class DSet
// o(n) for now
for (var ii :int = 0; ii < _entries.length; ii++) {
var entry :DSet_Entry = _entries[ii];
if (isSameKey(key, entry.getKey())) {
if (Util.equals(key, entry.getKey())) {
_entries.splice(ii, 1);
return entry;
}
@@ -180,7 +181,7 @@ public class DSet
var key :Object = elem.getKey();
for (var ii :int = 0; ii < _entries.length; ii++) {
var entry :DSet_Entry = _entries[ii];
if (isSameKey(key, entry.getKey())) {
if (Util.equals(key, entry.getKey())) {
_entries[ii] = elem;
return entry; // return the old entry
}
@@ -188,23 +189,6 @@ public class DSet
return null;
}
/**
* Internal function to determine whether a key matches the key for
* an existing entry.
*/
private function isSameKey (key :Object, otherKey :Object) :Boolean
{
if (ObjectUtil.isSimple(key)) {
return (key === otherKey);
} else if (key is Equalable) {
return (key as Equalable).equals(otherKey);
} else {
throw new Error("Element key is neither simple or Equalable");
}
}
/**
* Generates a string representation of this set instance.
*/
@@ -235,7 +219,6 @@ public class DSet
}
/** The entries of the set (in a sparse array). */
protected var _entries :TypedArray =
new TypedArray("[Lcom.threerings.presents.dobj.DSet$Entry;");
protected var _entries :TypedArray = TypedArray.create(DSet_Entry);
}
}