|
@@ -20,25 +20,35 @@
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
*/
|
|
|
|
|
|
+ import haxe.ds.StringMap;
|
|
|
+ import haxe.ds.IntMap;
|
|
|
+ import haxe.ds.HashMap;
|
|
|
+ import haxe.ds.ObjectMap;
|
|
|
+
|
|
|
@:multiType
|
|
|
abstract Map<K,V>(IMap < K, V > ) {
|
|
|
public function new();
|
|
|
|
|
|
- @:to static inline function toHash(t:IMap < String, V > ):haxe.ds.StringMap<V> {
|
|
|
- return new haxe.ds.StringMap<V>();
|
|
|
+ @:to static inline function toHash(t:IMap < String, V > ):StringMap<V> {
|
|
|
+ return new StringMap<V>();
|
|
|
}
|
|
|
|
|
|
- @:to static inline function toIntHash(t:IMap < Int, V > ):haxe.ds.IntMap<V> {
|
|
|
- return new haxe.ds.IntMap<V>();
|
|
|
+ @:to static inline function toIntHash(t:IMap < Int, V > ):IntMap<V> {
|
|
|
+ return new IntMap<V>();
|
|
|
}
|
|
|
|
|
|
- @:to static inline function toHashMap<K:{ function hashCode():Int; }>(t:IMap < K, V >):haxe.ds.HashMap<K,V> {
|
|
|
- return new haxe.ds.HashMap<K, V>();
|
|
|
+ @:to static inline function toHashMap<K:Hashable>(t:IMap < K, V >):HashMap<K,V> {
|
|
|
+ return new HashMap<K, V>();
|
|
|
}
|
|
|
|
|
|
- @:to static inline function toObjectMap<K:{ }>(t:IMap < K, V >):haxe.ds.ObjectMap<K,V> {
|
|
|
- return new haxe.ds.ObjectMap<K, V>();
|
|
|
+ @:to static inline function toObjectMap<K:{ }>(t:IMap < K, V >):ObjectMap<K,V> {
|
|
|
+ return new ObjectMap<K, V>();
|
|
|
}
|
|
|
+
|
|
|
+ @:from static inline function fromStringMap<V>(map:StringMap<V>):Map<String,V> return map
|
|
|
+ @:from static inline function fromIntMap<V>(map:IntMap<V>):Map<Int,V> return map
|
|
|
+ @:from static inline function fromHashMap<K:Hashable,V>(map:HashMap<K,V>):Map<K,V> return map
|
|
|
+ @:from static inline function fromObjectMap<K:{},V>(map:ObjectMap<K,V>):Map<K,V> return map
|
|
|
|
|
|
public inline function set(k:K, v:V) this.set(k, v)
|
|
|
public inline function get(k:K) return this.get(k)
|
|
@@ -56,3 +66,7 @@ private typedef IMap < K, V > = {
|
|
|
public function keys():Iterator<K>;
|
|
|
public function iterator():Iterator<V>;
|
|
|
}
|
|
|
+
|
|
|
+private typedef Hashable = {
|
|
|
+ function hashCode():Int;
|
|
|
+}
|