2 * (C) Copyright 2014 Jeremy Maitin-Shepard
4 * Use, modification, and distribution are subject to the terms specified in the
9 * Simple emulation of Map for Gecko versions < 13 Keys are based on
10 * string representation of Object, rather than Object identity, but
11 * for numbers and strings the effect is the same.
14 if (typeof(Map
) == "undefined") {
15 var Map
= function Map() {
19 Map
.prototype.get = function (k
) { return this.data
["K" + k
]; };
20 Map
.prototype.set = function (k
, v
) {
21 if (!(("K" + k
) in this.data
)) ++this.size
;
22 this.data
["K" + k
] = v
;
24 Map
.prototype.has = function (k
) { return ("K" + k
) in this.data
; };
25 Map
.prototype.delete = function (k
) {
26 if (("K" + k
) in this.data
) {
27 delete this.data
["K" + k
];
31 Map
.prototype.clear = function (k
) { this.data
= {}; this.size
= 0; };
33 // Note: This does not return in insertion order.
34 Map
.prototype.keys = function () {
39 // Note: This does not return in insertion order.
40 Map
.prototype.values = function () {
45 // Note: This does not return in insertion order.
46 Map
.prototype.entries = function () {
48 yield [k
.substring(1), this.data
[k
]];
51 Map
.prototype.forEach = function (callbackFn
, thisArg
) {
53 callbackFn
.call(thisArg
, k
.substring(1), this.data
[k
]);