java中的hashMap存取數據非常方便,可惜ASP中沒有類似的類.作者在開發程序中需要類似的數據類型,於是構造了一個能基本類似hashMap功能的類,可以實現鍵值存取操作等,存取的數據可以為ASP 中的任何基本類型.
下面是程序的代碼,貼到一個空的ASP中可以直接運行.有問題可以在這裡與我交流:
<%
'miantuanMap的使用范例
'作者:miantuan.net
'email:[email protected]
'qq:12694448
'交流區:http://www.miantuan.net
'實例化一個MtMap類的對象
set miantuanMap = new MtMap
'給mp對象賦值
miantuanMap.putv "a","miantuan.net"
miantuanMap.putv "b","www.miantuan.net"
miantuanMap.putv "c","http://www.miantuan.net"
response.write "[鍵值數量]:"&miantuanMap.count
response.write "<br>"
response.write "[a]:"&miantuanMap.getv("a")
response.write "<br>"
response.write ":"&miantuanMap.getv("b")
response.write "<br>"
response.write "[c]:"&miantuanMap.getv("c")
response.write "<hr>"
'刪除key為"b"的鍵值
miantuanMap.delv "b"
response.write "[鍵值數量]:"&miantuanMap.count
response.write "<br>"
response.write "[a]:"&miantuanMap.getv("a")
response.write "<br>"
response.write ":"&miantuanMap.getv("b")
response.write "<br>"
response.write "[c]:"&miantuanMap.getv("c")
response.write "<hr>"
'清空miantuanMap的所有值
miantuanMap.clear
'給key為"c"的鍵值重新賦值
miantuanMap.putv "c","http://miantuan.net"
response.write "[鍵值數量]:"&miantuanMap.count
response.write "<br>"
response.write "[a]:"&miantuanMap.getv("a")
response.write "<br>"
response.write ":"&miantuanMap.getv("b")
response.write "<br>"
response.write "[c]:"&miantuanMap.getv("c")
response.write "<hr>"
'-------------------------------------
'實現類似hashMap功能的類
'作者:miantuan.net
'email:[email protected]
'qq:12694448
Class MtMap