Java
2011,做開心的程序員
BlogJava
首頁
新隨筆
聯系
聚合
管理
隨筆 - 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)
數據庫(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請求中文亂碼
@注冊深圳公司
先保證服務器是POST用的是UTF-8的編碼。
嘗試從WEB提交一個POST請求,看中文亂碼否?
--rapin
閱讀排行榜
1.?華碩主板M2A-MX網卡驅動解決辦法(6434)
2.?SQL2000無法遠程連接解決方案(4923)
3.?sql 特定時間段的查詢(2920)
4.?IBM TDS 權限問題 LDAP: error code 50(2766)
5.?Android,HTTP請求中文亂碼(2193)
6.?清除Eclipse中的內置瀏覽器中的歷史記錄(1962)
7.?javascript中id和name的區別(1849)
8.?windows7下的tomcat筆記(1705)
9.?sqlite>經歷syntax error(1545)
10.?聯想Y450裝XP無法關機的解決方法(1164)
11.?Adobe Acrobat 9注冊碼(684)
12.?JAVA自帶DOM包操作XML(628)
13.?新手2步把sql2000轉oracle92(數據庫轉換)(583)
14.?操作active Directory,“安全”標簽(462)
15.?javascript仿Hashtable(405)
16.?EXECL做的MV(285)
17.?困擾許久的win10網絡問題(240)
評論排行榜
1.?華碩主板M2A-MX網卡驅動解決辦法(16)
2.?sql 特定時間段的查詢(4)
3.?JAVA自帶DOM包操作XML(1)
4.?Android,HTTP請求中文亂碼(1)
5.?IBM TDS 權限問題 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
閱讀(405)
評論(0)
編輯
收藏
所屬分類:
腳本語言
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
javascript仿Hashtable
javascript中id和name的區別
Copyright ©2025 rapin Powered by:
博客園
模板提供:
滬江博客
主站蜘蛛池模板:
双城市
|
渭南市
|
宁武县
|
永安市
|
桓台县
|
南川市
|
那曲县
|
澄江县
|
郸城县
|
肥西县
|
怀来县
|
吉隆县
|
宿州市
|
商南县
|
固始县
|
珲春市
|
大竹县
|
延吉市
|
隆安县
|
石家庄市
|
南丹县
|
昌黎县
|
平和县
|
天柱县
|
陕西省
|
喀喇
|
元氏县
|
高青县
|
阳山县
|
衡东县
|
陕西省
|
太白县
|
靖州
|
于田县
|
松潘县
|
巴南区
|
通榆县
|
承德县
|
丹棱县
|
泰安市
|
乐亭县
|