惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
人人都是产品经理
人人都是产品经理
The GitHub Blog
The GitHub Blog
月光博客
月光博客
T
Tailwind CSS Blog
小众软件
小众软件
Y
Y Combinator Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
B
Blog RSS Feed
博客园 - 司徒正美
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 聂微东
Microsoft Security Blog
Microsoft Security Blog
Recent Announcements
Recent Announcements
博客园 - Franky
U
Unit 42
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Azure Blog
Microsoft Azure Blog
T
The Blog of Author Tim Ferriss
GbyAI
GbyAI
Apple Machine Learning Research
Apple Machine Learning Research

博客园 - ttyp

火苗-批量改名最新V1.0.5 喂来猫-超强工具集最新版 V1.0.9.0 使用MemberShip时,用HttpWebRequest抓数据 ASP.NET图形化的曲线图类 JS写的一个功能齐备的treeview控件 输入自动完成类 定时检查网站是否掉线的批处理 code collection 0.44版 发布 JS代码的格式化和压缩 JS代码混淆初步 OUTLOOK菜单类 WEB打印分页类(JS) - ttyp - 博客园 自动配置IE代理脚本 XP下IIS不能添加扩展名映射的BUG js编写的语法高亮引擎 INF文件格式小结 自动提示效果 超强的WEB表格组件 关于设置WebControls里的treeview控件的图片路径
js写的Hashtable类
ttyp · 2005-07-30 · via 博客园 - ttyp

<script language="javascript" type="text/javascript">

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        = function(){for(var k in this._hash){delete this._hash[k];}}

}

var a = new Hashtable();

a.add(
"aa");
a.add(
"bb",2342);
a.add(
"bb",2342);

a.remove(
"aa");

alert(a.count());

alert(a.contains(
"bb"));

alert(a.contains(
"aa"));

alert(a.items(
"bb"));


</script>

生活学习

posted @ 2005-07-30 23:24  ttyp  阅读(5548)  评论(6)    收藏  举报