|
class Hashtable{constructor(){this.items={}}static newFrom(t){const s=new Hashtable;return s.items=t,s}put(t,s){this.items[t]=s}get(t){return this.items[t]}containsKey(t){return this.items.hasOwnProperty(t)}remove(t){delete this.items[t]}firstKey(){for(const t in this.items)if(this.items.hasOwnProperty(t))return t;return null}keys(t){t.length=0;for(const s in this.items)this.items.hasOwnProperty(s)&&t.push(s)}values(t){t.length=0;for(const s in this.items)this.items.hasOwnProperty(s)&&t.push(this.items[s])}clear(){for(const t in this.items)this.items.hasOwnProperty(t)&&delete this.items[t]}} |