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
"
));
查看全文
相关阅读:
HNU 12906 Battleship
codeforces 261 D
HDU 4939 Stupid Tower Defense(dp)
HDU 4941 Magical Forest(map映射+二分查找)杭电多校训练赛第七场1007
HDU 4902 Nice boat 2014杭电多校训练赛第四场F题(线段树区间更新)
【转载】使用Pandas对数据进行筛选和排序
【转载】使用pandas进行数据清洗
【转载】VC维的来龙去脉
Python-时间操作
Pandas-数据导入
原文地址:https://www.cnblogs.com/jacktu/p/1011504.html
最新文章
负载高,cpu不高
压测提示:Socket closed
tomcat打印接口延迟时间
nmon的使用
网络
c#基础语言编程-常用函数
c#基础语言编程-多态
c#基础语言编程-按值类型和引用类型传递参数
c#语言基础编程—string
c#语言基础编程-转义符
热门文章
c#基础编程—泛型
静态和非静态
c#调用钩子
获取windows系统信息
委托链
推荐ubuntu下的画图工具
ubuntu缺少libgtk-x11-2.0.so.0的解决办法
HDU 1064 Financial Management
HDU 1085 Holding Bin-Laden Captive!(DP)
HDU 3351 Seinfeld(括号匹配)
Copyright © 2011-2022 走看看