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
"
));
查看全文
相关阅读:
番外篇:生产要素最适投入分析(Optimum input of factors)
docker 9 :镜像存储机制
docker 8 : 容器资源限制管理
docker 7 :docker基本操作
docker 6:容器之间共享磁盘
docker 5 :挂载的方式
docker 4 : 容器数据卷使用
docker 3:创建镜像
docker 2:Docker镜像增删改查
docker 1:Docker安装(CentOS8.0)
原文地址:https://www.cnblogs.com/jacktu/p/1011504.html
最新文章
Geophysics背景知识(2)
Geophysics背景知识(1)
JavaScript笔记(1)
Ubuntu系统安装和使用搜狗输入法
NCR3网络技术速成笔记(1)
Lena——First Lady of Internet
独立分量分析(Independent Component Analysis)
四柱笔记(一):基本阴阳理论
德语词汇笔记(一)
日文文法笔记(一)
热门文章
导向滤波原理(Guided Filter)
双边滤波原理(Bilateral Filtering)
LeetCode小白菜笔记[10]:Implement strStr()
LeetCode小白菜笔记[9]:Remove Element
LeetCode小白菜笔记[8]:Remove Duplicates from Sorted Array
LeetCode小白菜笔记[7]:Merge Two Sorted Lists
LeetCode小白菜笔记[6]:Valid Parentheses
LeetCode小白菜笔记[5]:Longest Common Prefix
LeetCode小白菜笔记[4]:Roman to Integer
LeetCode小白菜笔记[3]:Palindrome Number
Copyright © 2011-2022 走看看