国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > VBScript > 正文

好玩的vbs特色代碼vbs棧類

2020-06-26 18:06:22
字體:
來源:轉載
供稿:網友
數據結構的問題相當重要,如果你能描述出一個問題的輸入和輸出數據結構,那么這個問題就大有希望,數據結構并不是C語言的專利,真正的數據結構是偽代碼的。下面這個棧類是我以前搜集別人的代碼,實際上每當考慮一個程序問題的時候,尤其是復雜的程序,就應該想到,用什么樣的數據去描述你的輸入和輸出。 

'********************************************** 
'        vbs棧類 
'        push(string)進棧 
'        getTop取棧頂元素 
'        pop去掉棧頂元素 
'        isempty是否???nbsp;
'        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 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 昆明市| 正阳县| 屯昌县| 衢州市| 莱阳市| 永德县| 稷山县| 台安县| 余江县| 洛宁县| 天水市| 芜湖市| 兴化市| 云南省| 台中市| 元氏县| 班戈县| 即墨市| 巨鹿县| 凤冈县| 娱乐| 理塘县| 烟台市| 余干县| 礼泉县| 花莲市| 德惠市| 灌南县| 金华市| 黑河市| 忻州市| 奉节县| 临桂县| 金寨县| 瑞丽市| 东光县| 克山县| 乐安县| 玉林市| 冷水江市| 黄大仙区|