好玩的vbs特色代碼vbs棧類
數(shù)據(jù)結(jié)構(gòu)的問題相當(dāng)重要,如果你能描述出一個(gè)問題的輸入和輸出數(shù)據(jù)結(jié)構(gòu),那么這個(gè)問題就大有希望,數(shù)據(jù)結(jié)構(gòu)并不是C語言的專利,真正的數(shù)據(jù)結(jié)構(gòu)是偽代碼的。下面這個(gè)棧類是我以前搜集別人的代碼,實(shí)際上每當(dāng)考慮一個(gè)程序問題的時(shí)候,尤其是復(fù)雜的程序,就應(yīng)該想到,用什么樣的數(shù)據(jù)去描述你的輸入和輸出。
'**********************************************
' vbs棧類
' push(string)進(jìn)棧
' getTop取棧頂元素
' pop去掉棧頂元素
' isempty是否???
' isfull是否棧滿(pMax設(shè)置了大小,可自行修改)
'
' 木鳥 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
相關(guān)文章
vbs實(shí)現(xiàn)恢復(fù)暫停的自動啟動服務(wù)的腳本
有時(shí)候我們需要把自啟動的服務(wù)停掉,方便我們處理事務(wù),但我們?nèi)绻淮瓮5舻淖詥臃?wù)比較多,如何一次性啟動他們呢2008-06-06VBS教程:VBscript語句-If...Then...Else 語句
If...Then...Else 語句用于計(jì)算條件是否為 True 或 False,并且根據(jù)計(jì)算結(jié)果指定要運(yùn)行的語句。通常,條件是使用比較運(yùn)算符對值或變量進(jìn)行比較的表達(dá)式。If...Then...Else 語句可以按照需要進(jìn)行嵌套2006-11-11使用ADSI、ASP和一對魔術(shù)戲法自動地創(chuàng)立一個(gè)虛擬目錄的方法
使用ADSI、ASP和一對魔術(shù)戲法自動地創(chuàng)立一個(gè)虛擬目錄的方法...2007-03-03