日期:2014-05-16  浏览次数:20383 次

javaScript-Hashtable
这是我同事有JavaScript模拟的HashTable
我有的地方看不明白,麻烦讲解下,谢谢
function   Hashtable()
{
        this._hash             =   new   Object();
        this.add                 =   function(key,value){
                                                if(typeof(key)!= "undefined "){
                                                        if(this.contains(key)==false){
                                                                this._hash[key]=typeof(value)== "undefined "?null:value;
                                                                return   true;
                                                        }   else   {
                                                                return   false;
                                                        }
                                                }   else   {
                                                        return   false;
                                                }
                                        }
        this.remove                 =   function(key){delete   this._hash[key];}
        this.count                 =   function(){var   i=0;for(var   k   in   this._hash){i++;}   return   i;}
        this.items                 =   function(key){return   this._hash[key];}
        this.contains         =   function(key){   return   typeof(this._hash[key])!= "undefined ";}
        this.clear   &