/** * @copyright vaalhaai.com * * <pre> * vaalhaai Map * * @author: Jimmy.Shine <Jimmy.Shine@Gmail.com> * @version: 1.0 * @date : Jan 3,2010 * @description: Map * </pre> */ function Map(){ this.keys = new Array(); this.datas = new Array(); this.put = function(key,value){ if(!this.containsKey(key)){ this.keys.push(key); } this.datas[key] = value; } this.get = function(key){ return this.datas[key]; } this.remove = function(key){ for(var i = 0;i<this.keys.length;i++){ if(key == this.keys[i]){ this.keys.splice(i,1); } } this.datas[key] = null; } this.clear = function(){ this.keys = null; this.datas = null; } this.containsKey = function(key){ for(var i = 0;i<this.keys.length;i++){ if(key == this.keys[i]){ return true; } } return false; } this.entrySet = function(){ return this.datas; } this.keySet = function(){ return this.keys; } this.isEmpty = function(){ return this.keys && this.keys.length >0; } this.values = function(){ var vs = new Array(this.keys.length); for(var i = 0;i<this.datas.length;i++){ vs[i] = datas[i]; } return vs; } }