Java
2011,做開心的程序員
BlogJava
首頁
新隨筆
聯(lián)系
聚合
管理
隨筆 - 16 文章 - 22 trackbacks - 0
<
2008年4月
>
日
一
二
三
四
五
六
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
7
8
9
10
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(3)
給我留言
查看公開留言
查看私人留言
我參與的團隊
深圳Java俱樂部(0/0)
隨筆分類
Android(1)
LDAP(2)
數(shù)據(jù)庫(3)
電腦(4)
腳本語言(2)
隨筆檔案
2015年11月 (1)
2015年7月 (1)
2012年7月 (1)
2010年7月 (1)
2010年6月 (1)
2010年3月 (1)
2009年12月 (2)
2009年1月 (1)
2008年10月 (2)
2008年8月 (1)
2008年4月 (4)
2008年3月 (1)
搜索
最新評論
1.?re: JAVA自帶DOM包操作XML
還是google好用 百度太垃圾了
--ttt
2.?re: Android,HTTP請求中文亂碼
@注冊深圳公司
先保證服務(wù)器是POST用的是UTF-8的編碼。
嘗試從WEB提交一個POST請求,看中文亂碼否?
--rapin
閱讀排行榜
1.?華碩主板M2A-MX網(wǎng)卡驅(qū)動解決辦法(6448)
2.?SQL2000無法遠程連接解決方案(4929)
3.?sql 特定時間段的查詢(2928)
4.?IBM TDS 權(quán)限問題 LDAP: error code 50(2780)
5.?Android,HTTP請求中文亂碼(2200)
6.?清除Eclipse中的內(nèi)置瀏覽器中的歷史記錄(1966)
7.?javascript中id和name的區(qū)別(1856)
8.?windows7下的tomcat筆記(1712)
9.?sqlite>經(jīng)歷syntax error(1549)
10.?聯(lián)想Y450裝XP無法關(guān)機的解決方法(1171)
11.?Adobe Acrobat 9注冊碼(690)
12.?JAVA自帶DOM包操作XML(633)
13.?新手2步把sql2000轉(zhuǎn)oracle92(數(shù)據(jù)庫轉(zhuǎn)換)(589)
14.?操作active Directory,“安全”標簽(473)
15.?javascript仿Hashtable(413)
16.?EXECL做的MV(291)
17.?困擾許久的win10網(wǎng)絡(luò)問題(247)
評論排行榜
1.?華碩主板M2A-MX網(wǎng)卡驅(qū)動解決辦法(16)
2.?sql 特定時間段的查詢(4)
3.?JAVA自帶DOM包操作XML(1)
4.?Android,HTTP請求中文亂碼(1)
5.?IBM TDS 權(quán)限問題 LDAP: error code 50(0)
javascript仿Hashtable
function
HashTable()
{
this
.Items
=
[];
this
.Count
=
function
()
{
return
this
.Items.length;}
;
//
長度
this
.DictionaryEntry
=
function
(key,value)
{
this
.Key
=
key
||
null
;
this
.Value
=
value
||
null
;
}
this
.Add
=
function
(key,value)
{
if
(
this
.ContainsKey(key))
{
return
false
;
}
else
{
this
.Items.push(
new
this
.DictionaryEntry(key,value));
return
true
;
}
}
this
.Clear
=
function
()
{
this
.Items.length
=
0
;}
this
.Remove
=
function
(key)
{
var
index
=
this
.GetIndexWithKey(key);
if
(index
>-
1
)
this
.Items.splice(index,
1
);
}
this
.GetValue
=
function
(key)
{
var
index
=
this
.GetIndexWithKey(key);
if
(index
>-
1
)
return
this
.Items[index].Value;
}
this
.ContainsKey
=
function
(key)
{
if
(
this
.GetIndexWithKey(key)
>-
1
)
return
true
;
return
false
;
}
this
.ContainsValue
=
function
(value)
{
if
(
this
.GetIndexWithValue(value)
>-
1
)
return
true
;
return
false
;
}
this
.Keys
=
function
()
{
var
iLen
=
this
.Count();
var
resultArr
=
[];
for
(
var
i
=
0
;i
<
iLen;i
++
)
resultArr.push(
this
.Items[i].Key);
return
resultArr;
}
this
.Values
=
function
()
{
var
iLen
=
this
.Count();
var
resultArr
=
[];
for
(
var
i
=
0
;i
<
iLen;i
++
)
resultArr.push(
this
.Items[i].Value);
return
resultArr;
}
this
.IsEmpty
=
function
()
{
return
this
.Count()
==
0
;}
this
.GetIndexWithKey
=
function
(key)
{
var
iLen
=
this
.Count();
for
(
var
i
=
0
;i
<
iLen;i
++
)
if
(
this
.Items[i].Key
===
key)
return
i;
return
-
1
;
}
this
.GetIndexWithValue
=
function
(value)
{
var
iLen
=
this
.Count();
for
(
var
i
=
0
;i
<
iLen;i
++
)
if
(
this
.Items[i].Value
===
value)
return
i;
return
-
1
;
}
}
var
my
=
new
HashTable();
my.Add(
"
name
"
,
"
blueKnight
"
);
my.Add(
"
age
"
,'
24
');
my.Add(
"
sex
"
,
"
boy
"
);
alert(my.Add(
"
sex
"
,
"
sex
"
));
//
已添加過的返回false
alert(my.Count());
alert(my.ContainsValue(
"
boy
"
));
//
alert(my.GetValue("name"))
for
(
var
i
in
my.Items)
//
遍歷
{
alert(
"
Key:
"
+
my.Items[i].Key
+
"
--Value:
"
+
my.Items[i].Value);
}
my.Remove(
"
age
"
);
//
刪除
alert(my.Keys()
+
'
-
'
+
my.Values()
+
'\n\r');
posted on 2008-04-03 12:22
rapin
閱讀(413)
評論(0)
編輯
收藏
所屬分類:
腳本語言
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發(fā)表評論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關(guān)文章:
javascript仿Hashtable
javascript中id和name的區(qū)別
Copyright ©2025 rapin Powered by:
博客園
模板提供:
滬江博客
主站蜘蛛池模板:
巴林右旗
|
江川县
|
德清县
|
大新县
|
科技
|
江城
|
美姑县
|
平顺县
|
思茅市
|
土默特右旗
|
仲巴县
|
奈曼旗
|
老河口市
|
迁西县
|
大同县
|
土默特右旗
|
石台县
|
南通市
|
怀柔区
|
和静县
|
惠州市
|
湘潭县
|
岳阳县
|
松原市
|
成安县
|
武隆县
|
嘉定区
|
文化
|
哈尔滨市
|
博湖县
|
定远县
|
乌兰浩特市
|
平乐县
|
油尖旺区
|
临沂市
|
织金县
|
屯门区
|
清流县
|
达州市
|
阆中市
|
竹溪县
|