欢迎光临
我们一直在努力

vbs(asp)的栈类

建站超值云服务器,限时71元/月

  用js可以用array对象很容易的实现栈的功能,但在vbs中没有相应的功能,没办法,只有自己动手了:(

  如果你的栈不了解请查看数据结构的相关内容。这个栈类是参照c++的栈类写的,用法一样。用这个类你也可以很方便的修改出队列的类:)

<%

**********************************************

vbs栈类

push(string)进栈

gettop取栈顶元素

pop去掉栈顶元素

isempty是否栈空

isfull是否栈满(pmax设置了大小,可自行修改)

木鸟 2002.10.10

http://www.aspsky.net/

**********************************************

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

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » vbs(asp)的栈类
分享到: 更多 (0)

相关推荐

  • 暂无文章