|
@@ -22,6 +22,8 @@
|
|
|
|
|
|
package haxe.ds;
|
|
|
|
|
|
+import haxe.iterators.HashMapKeyValueIterator;
|
|
|
+
|
|
|
/**
|
|
|
HashMap allows mapping of hashable objects to arbitrary values.
|
|
|
|
|
@@ -40,7 +42,7 @@ abstract HashMap<K:{function hashCode():Int;}, V>(HashMapData<K, V>) {
|
|
|
/**
|
|
|
See `Map.set`
|
|
|
**/
|
|
|
- public inline function set(k:K, v:V) {
|
|
|
+ @:arrayAccess public inline function set(k:K, v:V) {
|
|
|
this.keys.set(k.hashCode(), k);
|
|
|
this.values.set(k.hashCode(), v);
|
|
|
}
|
|
@@ -48,7 +50,7 @@ abstract HashMap<K:{function hashCode():Int;}, V>(HashMapData<K, V>) {
|
|
|
/**
|
|
|
See `Map.get`
|
|
|
**/
|
|
|
- public inline function get(k:K) {
|
|
|
+ @:arrayAccess public inline function get(k:K) {
|
|
|
return this.values.get(k.hashCode());
|
|
|
}
|
|
|
|
|
@@ -91,6 +93,13 @@ abstract HashMap<K:{function hashCode():Int;}, V>(HashMapData<K, V>) {
|
|
|
return this.values.iterator();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ See `Map.keyValueIterator`
|
|
|
+ **/
|
|
|
+ public inline function keyValueIterator():HashMapKeyValueIterator<K, V> {
|
|
|
+ return new HashMapKeyValueIterator(cast this);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
See `Map.clear`
|
|
|
**/
|