JavaScript 写的key-value数组

// JavaScript Key-Value Array

// cheungmine

function _pair_array_t (keyCompFunc) { this._keys = new Array(); this._vals = new Array(); this._comp = function (k1, k2) { return (k1==k2); } this.npos = -1; // DONOT change this if (keyCompFunc != null) this._comp = keyCompFunc; this.insert = function (key, value) { for (var i=0; i

使用:

var map = new _pair_array_t();
map.insert("zhang", "hello");
map.insert("liang", "world");
alert(map.size());
map.erase("zhang");
alert(map.size());
alert(map.find("zhang"));

你可能感兴趣的:(JavaScript 写的key-value数组)