好玩的vbs特色代码vbs栈类

发布时间:2022-04-17 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了好玩的vbs特色代码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 &amp; 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

脚本宝典总结

以上是脚本宝典为你收集整理的好玩的vbs特色代码vbs栈类全部内容,希望文章能够帮你解决好玩的vbs特色代码vbs栈类所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: