vbs(asp)的栈类

2016-01-29 20:22 6 1 收藏

vbs(asp)的栈类,vbs(asp)的栈类

【 tulaoshi.com - ASP 】

用js可以用array对象很容易的实现栈的功能,但在vbs中没有相应的功能,没办法,只有自己动手了:(
  如果你的栈不了解请查看数据结构的相关内容。这个栈类是参照c++的栈类写的,用法一样。用这个类你也可以很方便的修改出队列的类:)

<%
'**********************************************
' vbs栈类
' push(string)进栈
' getTop取栈顶元素
' pop去掉栈顶元素
' isempty是否栈空
' isfull是否栈满(pMax设置了大小,可自行修改)
'
' 木鸟 2002.10.10
' http://www.aspsky.net/
'**********************************************

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

class Stack
private pArr, pString, pMax
private tab
private sub class_initialize()
tab=chr(9)
pMax=1000 '最大容量
end sub
private sub class_terminate()
if isarray(pArr) then
erase pArr
end if
end sub

public function push(str)
if str<"" and instr(str,tab)<1 and not Isfull then
if isarray(pArr) then
pString=join(pArr,tab)
end if
pString=pString & tab & str
pArr=split(pString,tab)
push=true
else
push=false
end if
end function

public function GetTop()
if not isarray(pArr)<0 then
GetTop=null
else
if ubound(pArr)<0 then
GetTop=null
else
GetTop=pArr(Ubound(pArr))
end if
end if
end function

public function Pop()
if not isArray(pArr) then
Pop=false
else
if Ubound(pArr)<0 then
Pop=false
else
pString=join(pArr,tab)
pString=left(pString,inStrRev(pString,tab)-1)
pArr=split(pString,tab)
Pop=true
end if
end if
end function

public function Isempty()
if not isArray(pArr) then
Isempty=true
else
if Ubound(pArr)<0 then
isempty=true
else
isempty=false
end if
end if
end function

public function Isfull()
if not isArray(pArr) then
Isfull=false
else
if ubound(pArr)<pMax then
Isfull=false
else
Isfull=true
end if
end if
end function
end class
%

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/asp/)

来源:https://www.tulaoshi.com/n/20160129/1511095.html

延伸阅读
标签: Web开发
Class 声明  声明一个类的名字,就是定义一些变量,属性,方法来组成一个类   这是真的!!!?VBScript中能用类!?!?不知道能不能用于ASP!?这样的话,我就不是能写出像object一样的ASP程序?!说干就干!实践是检验真理的唯一标准,自个动手吧!  我们常常看到别的程序语言中中都有类的说明,PHP,VB,C++,...
标签: ASP
  VBScript5中增加了许多新功能,最振奋人心的当属类和正则表达式的出现。以下是本人写的一个解析html代码的类。我是 学php的,语法有不习惯的地方,请大家多包含。 <% Class HTMLParse     ' 设置 Initialize 事件。     Private Sub Class_Initialize      &nbs...
标签: Web开发
作者的blog: http://blog.csdn.net/oyiboy/ 我之所以还是要宣扬用MVC来开发ASP,只是想让面向过程的思考方式变成面向对象的思考方式,这个对于任何一种语言的开发员来说都是有好处的。 MVC是个标准模型,ASP要实现似乎真的是很困难,但是标准是标准,运用是运用,既然ASP要实现这个模型很难,那可以尝试着将MVC模型变形成适合自己的模型...
标签: Web开发
Class 声明 声明一个类的名字,就是定义一些变量,属性,方法来组成一个类。我们常常看到别的程序语言中中都有类的说明,PHP,VB,C++,这个在VBScript中的类的说明,我是第一次听到,我们的日常工作就是网站开发,在这个里面多多少少搞出点经验,像模像样也能自诩为"内行",所以我就来分享一下我所知道的这个新的东东。我们来看看下面的这个...
标签: ASP
class Base64Class rem Const dim sBASE_64_CHARACTERS'转化码 dim lenString '计算字符串的长度 dim iCount '计数器 dim returnValue '返回值 dim tempChar'缓存字符 dim tempString'缓存字符串 dim paramString '参数字符串 dim temHex'缓存缓存十六进制 dim tempLow'缓存低位 dim tem...

经验教程

47

收藏

14
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部