您现在的位置: 万盛学电脑网 >> 程序编程 >> 网络编程 >> asp编程 >> 正文

用ASP实现hashMap功能的类

作者:佚名    责任编辑:admin    更新时间:2022-06-22

   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