好玩的vbs特色代码vbs栈类
好玩的vbs特色代码vbs栈类
发布时间:2016-12-28 来源:查字典编辑
摘要:数据结构的问题相当重要,如果你能描述出一个问题的输入和输出数据结构,那么这个问题就大有希望,数据结构并不是C语言的专利,真正的数据结构是伪代...

数据结构的问题相当重要,如果你能描述出一个问题的输入和输出数据结构,那么这个问题就大有希望,数据结构并不是C语言的专利,真正的数据结构是伪代码的。下面这个栈类是我以前搜集别人的代码,实际上每当考虑一个程序问题的时候,尤其是复杂的程序,就应该想到,用什么样的数据去描述你的输入和输出。

'**********************************************

'vbs栈类

'push(string)进栈

'getTop取栈顶元素

'pop去掉栈顶元素

'isempty是否栈空

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

'

'木鸟2002.10.10

'http://www.aspsky.net/

'**********************************************

classStack

privatepArr,pString,pMax

privatetab

privatesubclass_initialize()

tab=chr(9)

pMax=1000'最大容量

endsub

privatesubclass_terminate()

ifisarray(pArr)then

erasepArr

endif

endsub

publicfunctionpush(str)

ifstr<>""andinstr(str,tab)<1andnotIsfullthen

ifisarray(pArr)then

pString=join(pArr,tab)

endif

pString=pString&tab&str

pArr=split(pString,tab)

push=true

else

push=false

endif

endfunction

publicfunctionGetTop()

ifnotisarray(pArr)<0then

GetTop=null

else

ifubound(pArr)<0then

GetTop=null

else

GetTop=pArr(Ubound(pArr))

endif

endif

endfunction

publicfunctionPop()

ifnotisArray(pArr)then

Pop=false

else

ifUbound(pArr)<0then

Pop=false

else

pString=join(pArr,tab)

pString=left(pString,inStrRev(pString,tab)-1)

pArr=split(pString,tab)

Pop=true

endif

endif

endfunction

publicfunctionIsempty()

ifnotisArray(pArr)then

Isempty=true

else

ifUbound(pArr)<0then

isempty=true

else

isempty=false

endif

endif

endfunction

publicfunctionIsfull()

ifnotisArray(pArr)then

Isfull=false

else

ifubound(pArr)<pMaxthen

Isfull=false

else

Isfull=true

endif

endif

endfunction

endclass

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新vbs学习
热门vbs学习
脚本专栏子分类