Here is an orderly mapping. It should be a hash table, which is really no understanding of JavaScript, can only use this. Find complexity is log (n) // list node function entry (key, value) {this.key = key; this.value = value;}
// ordered mapping function SortedMap (capacity, autoIncrease) {this.capacity = capacity; this.autoIncrease = autoIncrease; this.size = 0; this.ensureCapacity = ensureCapacity; this.add = add; this.search = search; THIS.BUFFER = New Array (Capacity); this.getIndex = getIndex; this.get = get;} function ensurecapacity () {if (this.antocrease && (this.size> = this.Array.Length)) {var Old = this.buffer; this.buffer = new array ((this.buffer.Length 1) * 2); for (var i = 0; i Function add (entry) {this.ensurecapacity (); var index = this.GetIndex (entry.key); for (var i = this.size; i> index;) {this.buffer [i] = this.buffer [ --i]; THIS.BUFFER [index] = entry; this.size ;} function getIndex (key) {if (this.size == 0) Return 0; var min = 0, max = this.size-1; var mID = 0; While (min <= max) {mid = (min max) >> 1; if (key == this.buffer [mid] .key) {return mid;} else} (key