|
@@ -33,7 +33,9 @@ class IntHash<T> {
|
|
|
Creates a new empty hashtable.
|
|
|
**/
|
|
|
public function new() : Void {
|
|
|
- #if flash
|
|
|
+ #if flash9
|
|
|
+ h = new flash.utils.Dictionary();
|
|
|
+ #else flash
|
|
|
h = untyped __new__(_global["Object"]);
|
|
|
#else neko
|
|
|
h = untyped __dollar__hnew(0);
|
|
@@ -81,7 +83,9 @@ class IntHash<T> {
|
|
|
a [null] value versus no value.
|
|
|
**/
|
|
|
public function exists( key : Int ) : Bool {
|
|
|
- #if flash
|
|
|
+ #if flash9
|
|
|
+ return untyped h.hasOwnProperty(key);
|
|
|
+ #else flash
|
|
|
return untyped h["hasOwnProperty"](key);
|
|
|
#else js
|
|
|
return untyped h[key] != null;
|
|
@@ -96,7 +100,11 @@ class IntHash<T> {
|
|
|
there was such entry.
|
|
|
**/
|
|
|
public function remove( key : Int ) : Bool {
|
|
|
- #if flash
|
|
|
+ #if flash9
|
|
|
+ if( untyped !h.hasOwnProperty(key) ) return false;
|
|
|
+ untyped __delete__(h,key);
|
|
|
+ return true;
|
|
|
+ #else flash
|
|
|
if( untyped !h["hasOwnProperty"](key) ) return false;
|
|
|
untyped __delete__(h,key);
|
|
|
return true;
|
|
@@ -114,7 +122,9 @@ class IntHash<T> {
|
|
|
Returns an iterator of all keys in the hashtable.
|
|
|
**/
|
|
|
public function keys() : Iterator<Int> {
|
|
|
- #if flash
|
|
|
+ #if flash9
|
|
|
+ return untyped (__keys__(h)).iterator();
|
|
|
+ #else flash
|
|
|
var l : Array<Int> = untyped __keys__(h);
|
|
|
for( x in 0...l.length )
|
|
|
l[x] = Std.int(l[x]);
|
|
@@ -138,7 +148,14 @@ class IntHash<T> {
|
|
|
Returns an iterator of all values in the hashtable.
|
|
|
**/
|
|
|
public function iterator() : Iterator<T> {
|
|
|
- #if flash
|
|
|
+ #if flash9
|
|
|
+ return untyped {
|
|
|
+ ref : h,
|
|
|
+ it : keys(),
|
|
|
+ hasNext : function() { return this.it.hasNext(); },
|
|
|
+ next : function() { var i = this.it.next(); return this.ref[i]; }
|
|
|
+ };
|
|
|
+ #else flash
|
|
|
return untyped {
|
|
|
ref : h,
|
|
|
it : keys(),
|