存储数据键和项目对的类(Dictionary对象)

<%

Class Dictionary

Public Copyright, Developer, Name, Version, Web

Private aryKey() 

Private aryItem() 

Private iCompareMode

Private Sub Class_Initialize() 

'请保留此信息 

Copyright = "2002 www.ChinaOK.Net, All rights reserved." 

Developer = "ChinaOK" 

Name = "Dictionary" 

Version = "1.0b" 

Web = "http://www.ChinaOK.Net" 

Redim aryKey(0) 

Redim aryItem(0) 

aryKey(0)="" 

aryItem(0)="" 

iCompareMode=0 

End Sub

Public Function Add(sKey,Item) 

InsertSort sKey,Item 

End Function

Public Function Exists(sKey) 

If BinSearch(sKey)=0 Then 

Exists=false 

Else 

Exists=True 

End if 

End Function

Public Function Items() 

Items=aryItem 

End Function

Public Function Keys() 

Keys=aryKey 

End Function

Public Function Remove(sKey) 

DeleteSort sKey 

End Function

Public Function RemoveAll() 

Redim aryKey(0) 

Redim aryItem(0) 

aryKey(0)="" 

aryItem(0)="" 

End Function

Property Get Count() 

Dim Len1,Len2 

Len1=ubound(aryKey) 

Len2=ubound(aryItem) 

If Len1<>Len2 Then Redim Preserve aryItem(Len1) 

Count=Len1 

End Property

Property Get Item(sKey) 

Dim iTop 

iTop=0 

iTop = BinSearch(sKey) 

If iTop<>0 Then 

Item=aryItem(iTop) 

Else 

Add sKey,"" 

Item="" 

End If 

End Property

Property Let Item(sKey,NewItem) 

Dim iTop 

iTop=0 

iTop = BinSearch(sKey) 

If iTop<>0 Then 

aryItem(iTop)=NewItem 

Else 

Add sKey,NewItem 

End If 

End Property

Property Let Key(sKey,sNewKey) 

Dim iTop 

iTop = 0 

iTop = BinSearch(sKey) 

If iTop<>0 Then 

aryKey(iTop)=sNewKey 

Else 

Err.Raise 19782,"myDictionary","未找到元素" & sKey,"",0 

End If 

End Property

Property Let CompareMode(iMode) 

If Count()>0 Then Err.Raise 19783,"myDictionary","设置字符串keyword比較模式必须在Items为空时设置","",0 

If (iMode<>0 And iMode<>1) Then iMode=0 

iCompareMode=iMode 

End Property

Property Get CompareMode() 

CompareMode=iCompareMode 

End Property

Private Function BinSearch(sKey) 

'折半查找算法 

Dim Result 

Result=0 

Dim iHigh,iLow,iMid 

iHigh = Count() 

iLow = 1 

Do While (iLow<=iHigh) 

iMid=(iLow+iHigh)\2 

If strComp(aryKey(iMid),sKey,iCompareMode)=0 Then 

Result=iMid 

Exit Do 

End If 

If strComp(aryKey(iMid),sKey,iCompareMode)=1 Then 

iHigh=iMid-1 

Else 

iLow=iMid+1 

End if 

Loop 

BinSearch=Result 

End Function

Private Function DeleteSort(sKey) 

Dim iTop,I,iLen 

iTop=BinSearch(sKey) 

If iTop=0 Then 

Err.Raise

End Function

存储数据键和项目对的类(Dictionary对象)的更多相关文章

  1. JavaWeb_EL表达式存储数据及获得项目路径

    菜鸟教程 传送门 EL表达式[百度百科]:EL(Expression Language) 是为了使JSP写起来更加简单.表达式语言的灵感来自于 ECMAScript 和 XPath 表达式语言,它提供 ...

  2. [C++]变量存储类别,指针和引用,类与对象,继承与派生的一些摘要

    C++中共有四种存储类别标识符:auto/static/register/extern 1.auto 函数或分程序内定义的变量(包括形参)可以定义为auto(自动变量).如果不指定存储类别,则隐式定义 ...

  3. Android中数据存储(三)——SQLite数据库存储数据

    当一个应用程序在Android中安装后,我们在使用应用的过程中会产生很多的数据,应用都有自己的数据,那么我们应该如何存储数据呢? 数据存储方式 Android 的数据存储有5种方式: 1. Share ...

  4. 8.7 JSON存储数据方式(JavaScript对象表示法)

    8.7 JSON存储数据方式(JavaScript对象表示法) JSON JavaScript 对象表示法(JavaScript Object Notation) 是一种存储数据的方式. 一.创建JS ...

  5. C#核心基础--浅谈类和对象的概念

    浅谈类和对象的概念 一.什么是类?什么是对象? 学习一门面向对象编程语言,我们必须得知道什么是类?什么是对象? 类(Class)实际上是对某种类型的对象定义变量和方法的原型.它表示对现实生活中一类具有 ...

  6. C#面向对象基础 —— 类与对象

    文章来源: https://www.cnblogs.com/huluobozu/p/5070500.html 一.类与对象 类是面向对象编程的基本单元:类造出来的变量叫对象. 一个类包含俩种成员:字段 ...

  7. C#面向对象基础--类与对象

    1.类与对象 类是面向对象编程的基本单元:类造出来的变量叫对象. 一个类包含俩种成员:字段与方法. 字段即变量,方法即函数. 面向对象思想:教给我们如何合理的运用类的规则去编写代码. 2.类的字段 字 ...

  8. 一个Web项目中实现多个数据库存储数据并相互切换用过吗?

    最近公司一个项目需要连接多个数据库(A和B)操作,根据不同的业务模块查询不同的数据库,因此需要改造下之前的spring-mybatis.xml配置文件以及jdbc.properties配置文件,项目后 ...

  9. android开发中的5种存储数据方式

    数据存储在开发中是使用最频繁的,根据不同的情况选择不同的存储数据方式对于提高开发效率很有帮助.下面笔者在主要介绍Android平台中实现数据存储的5种方式. 1.使用SharedPreferences ...

随机推荐

  1. 开放源代码的微微信.NET 0.8 版公布了

    微微信.NET 0.8 版公布了     A.源代码应用范围:         未认证的和经过认证的微信订阅号.微信服务号均可使用,本源代码的每个模块都提供全然的 ASP.NET C#源代码,绝对不含 ...

  2. 控制台打印Hibernate的SQL语句显示绑定参数值

    问题? 使用Hibernate提供的show_sql内置属性true只能输出类似于下面的SQL语句:Hibernate:   insert into user(name,password) value ...

  3. (017)将一棵二叉查找树重构成链表(keep it up)

    给定一棵二叉查找树,设计算法,将每一层的全部结点构建为一个 链表(也就是说, 假设树有D层,那么你将构建出D个链表). 这个题实质是个BFS,可是实现起来有点麻烦,又不像常见的BFS, 所以编写代码时 ...

  4. iOS7 文本转语音 AVSpeechSynthesizer

    OS7 的这个功能确实不错.我刚试了下,用官方提供的API ,简单的几句代码就能实现文本转语音! Xcode 5.0 工程建好后首先把AVFoundation.framework 加入到工程 AVSp ...

  5. css实现自适应屏幕高度

    body,html{ margin:0px; height:100%; }

  6. A Game of Thrones(0) - PROLOGUE

    "We should start back", Gared urged as the woods began to grow dark around them. "The ...

  7. windows使用nginx+memcached实现负载均衡和session或者缓存共享

    windows使用nginx+memcached实现负载均衡和session或者缓存共享 两台server server1:115.29.186.215 windows2008 64位操作系统 ser ...

  8. 一些Android框架

    从网上收集一些框架,敲代码偷懒这些框架非常实用,必须记下来,为了以后少写代码,用别人好的框架 ThinkAndroid ThinkAndroid(一个ThinkAndroid教程地址:http://m ...

  9. 基于Android 下载文件时,更新UI简单帮助类

    因为在项目开发时.有这种简单需求,问谷歌,网络上也有好多Utils工具类,可是比較冗余.自己就简单的写了一个简单帮助类. /** * 下载文件,更新UI简单帮助类 * * @author jarlen ...

  10. swift 学习资源 大集合

    今天看到一个swift学习网站,其中我们收集了大量的学习资源 Swift 介绍 Swift 介绍 来自 Apple 官方 Swift 简单介绍 (@peng_gong) 一篇不错的中文简单介绍 [译] ...