zoukankan
html css js c++ java
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
=
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
"
));
查看全文
相关阅读:
select下拉的value和option内值得获取
express模块下GET和POST获取前台数据
Node.js---fs模块
Node.js---MySQL的增删改查
Node.js--mysql的应用
Node.js-router(将大服务拆分成一个个小服务)
22
窗口切换
IO
第一次实训作业
原文地址:https://www.cnblogs.com/jacktu/p/1011504.html
最新文章
总结
C语言I博客作业09
C语言I博客作业08
C语言I博客作业07
C语言I博客作业06
C语言I博客作业05
飞机订票系统_Stage3
飞机订票系统_Stage2
飞机订票系统_Stage1
19.04.17JavaWeb and SQL作业
热门文章
19.04.10JavaWeb and SQL作业
19.04.03JavaWeb and SQL作业
19.03.27JavaWeb作业
19.03.20JavaWeb作业
19.03.14JavaWeb作业
19.03.11安装glassfish的错误
boxsizing:border-box
button是否可以点击-disabled
Vue.js----v-on的使用
Vue中methods与computed的区别
Copyright © 2011-2022 走看看