|
22 | 22 |
|
23 | 23 | package haxe.ds; |
24 | 24 |
|
| 25 | +#if (hl_ver >= version("1.13.0") && !hl_legacy32) |
| 26 | + |
25 | 27 | @:coreApi |
26 | 28 | class Int64Map<T> implements haxe.Constraints.IMap<haxe.Int64, T> { |
27 | 29 | var h:hl.types.Int64Map; |
@@ -82,18 +84,82 @@ class Int64Map<T> implements haxe.Constraints.IMap<haxe.Int64, T> { |
82 | 84 | } |
83 | 85 |
|
84 | 86 | public function clear():Void { |
85 | | - #if (hl_ver >= version("1.11.0")) |
86 | 87 | @:privateAccess h.clear(); |
87 | | - #else |
88 | | - h = new hl.types.Int64Map(); |
89 | | - #end |
90 | 88 | } |
91 | 89 |
|
92 | 90 | public function size():Int { |
93 | | - #if (hl_ver >= version("1.12.0")) |
94 | 91 | return h.size(); |
95 | | - #else |
96 | | - return h.keysArray().length; |
97 | | - #end |
98 | 92 | } |
99 | 93 | } |
| 94 | + |
| 95 | +#else |
| 96 | + |
| 97 | +// Same as haxe.ds.Int64Map |
| 98 | +class Int64Map<T> implements haxe.Constraints.IMap<haxe.Int64, T> { |
| 99 | + var m : Map<String,T>; |
| 100 | + |
| 101 | + public function new():Void { |
| 102 | + m = new Map(); |
| 103 | + } |
| 104 | + |
| 105 | + public function set(key:Int64, value:T):Void { |
| 106 | + m.set(key.toString(),value); |
| 107 | + } |
| 108 | + |
| 109 | + public function get(key:Int64):Null<T> { |
| 110 | + return m.get(key.toString()); |
| 111 | + } |
| 112 | + |
| 113 | + public function exists(key:Int64):Bool { |
| 114 | + return m.exists(key.toString()); |
| 115 | + } |
| 116 | + |
| 117 | + public function remove(key:Int64):Bool { |
| 118 | + return m.remove(key.toString()); |
| 119 | + } |
| 120 | + |
| 121 | + public function keys():Iterator<Int64> { |
| 122 | + var it = m.keys(); |
| 123 | + return { |
| 124 | + hasNext : () -> it.hasNext(), |
| 125 | + next: () -> { |
| 126 | + return haxe.Int64.parseString(it.next()); |
| 127 | + } |
| 128 | + }; |
| 129 | + } |
| 130 | + |
| 131 | + public function iterator():Iterator<T> { |
| 132 | + return m.iterator(); |
| 133 | + } |
| 134 | + |
| 135 | + public function keyValueIterator():KeyValueIterator<Int64, T> { |
| 136 | + var it = m.keyValueIterator(); |
| 137 | + return { |
| 138 | + hasNext : () -> it.hasNext(), |
| 139 | + next : () -> { |
| 140 | + var v = it.next(); |
| 141 | + return { key : haxe.Int64.parseString(v.key), value : v.value }; |
| 142 | + } |
| 143 | + }; |
| 144 | + } |
| 145 | + |
| 146 | + public function copy():Int64Map<T> { |
| 147 | + var v = new Int64Map(); |
| 148 | + v.m = m.copy(); |
| 149 | + return v; |
| 150 | + } |
| 151 | + |
| 152 | + public function toString():String { |
| 153 | + return m.toString(); |
| 154 | + } |
| 155 | + |
| 156 | + public function clear():Void { |
| 157 | + m.clear(); |
| 158 | + } |
| 159 | + |
| 160 | + public function size():Int { |
| 161 | + return m.size(); |
| 162 | + } |
| 163 | +} |
| 164 | + |
| 165 | +#end |
0 commit comments