Added the keys() function to the Map interface, replaced instances of

SimpleMap with HashMap. Discarded SimpleMap.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4122 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-05-16 21:06:06 +00:00
parent 4aa8f5a5d5
commit 64e87bb907
12 changed files with 36 additions and 85 deletions
+6
View File
@@ -18,5 +18,11 @@ public class Byte
{
return (other is Byte) && (value === (other as Byte).value);
}
// documentation inherited
public function toString () :String
{
return "Byte(" + value + ")";
}
}
}
+1
View File
@@ -192,6 +192,7 @@ public class Hashtable
return _simpleSize + _entriesSize;
}
// documentation inherited from interface Map
public function keys () :Array
{
var keys :Array = new Array();
+5
View File
@@ -26,6 +26,11 @@ public interface Map
*/
function isEmpty () :Boolean;
/**
* Return all the unique keys in this Map, in Array form.
*/
function keys () :Array;
/**
* Store a value in the map associated with the specified key.
* Returns the previous value stored for that key, or undefined.
+1 -1
View File
@@ -177,7 +177,7 @@ public class MessageManager
// protected var _loader :ClassLoader;
/** A cache of instantiated message bundles. */
protected var _cache :SimpleMap = new SimpleMap();
protected var _cache :HashMap = new HashMap();
/** Our top-level message bundle, from which others obtain messages if
* they can't find them within themselves. */
-58
View File
@@ -1,58 +0,0 @@
package com.threerings.util {
/**
* I will likely extend this out to be a fully-featured map.
*/
public class SimpleMap extends Object
{
public function clear () :void
{
_data = new Object();
_size = 0;
}
public function get (key :Object) :Object
{
var skey :String = key.toString();
return _data[skey];
}
public function keys () :Array
{
var arr :Array = new Array();
for (var skey :String in _data) {
arr.push(skey);
}
return arr;
}
public function put (key :Object, value :Object) :Object
{
var skey :String = key.toString();
var oldValue :* = _data[skey];
_data[skey] = value;
if (oldValue === undefined) {
_size++;
}
return (oldValue as Object);
}
public function remove (key :Object) :Object
{
var skey :String = key.toString();
var value :Object = _data[skey];
delete _data[skey];
_size--;
return value;
}
public function size () :int
{
return _size;
}
protected var _data :Object = new Object();
protected var _size :int = 0;
}
}