<%
'**********************************************
' File: Stack.asp
' Version: willpower Stack Class Version 0.1 Build 20080614
' Author: willpower
' Email: wise.willpower@163.com
' QQ:20934440
' Date: 06/14/2008
' Comments: The code for the Stack.
' This can free usage, but please
' not to delete this copyright information.
' If you have a modification version,
' Please send out a duplicate to me.
'**********************************************
' 文件名: Stack.asp
' 版本: willpower Stack Class Version 0.1 Build 20080614
' 作者: willpower(wise.willpower)
' 电子邮件: wise.willpower@163.com
' QQ:20934440
' 日期: 2008年04月30日
' 声明: 栈类
' 本栈类可以自由使用,但请保留此版权声明信息
' 如果您对本栈类进行修改增强,
' 请发送一份给俺。
Class Stack
Private max
Private increment
Private arrayStack()
Private top
Private Sub Class_Initialize()
Call Initialize()
End Sub
Private Sub Class_Terminate()
Call Terminate()
End Sub
Private Sub Initialize()
max = 100
increment = 10
Redim arrayStack(increment)
top = 0
End Sub
Private Sub Terminate()
If IsArray(arrayStack) Then Erase arrayStack
End Sub
Public Sub InitStack()
Call Terminate()
Call Initialize()
End Sub
Public Function IsEmpty()
IsEmpty = False
If top = 0 Then IsEmpty = True
End Function
Public Function IsFull()
IsFull = False
If top < Ubound(arrayStack) Then Exit Function
If top < max Then Redim Preserve arrayStack(top + increment):Exit Function
IsFull = True
End Function
Public Function Push(ByVal str)
Push = False
If str = "" Then Err.Raise 3,"String is empty":Exit Function
If IsFull Then Err.Raise 1,"Stack overflow":Exit Function
top = top + 1
arrayStack(top) = str
Push = True
End Function
Public Function Pop()
Pop = False
If IsEmpty Then Err.Raise 2,"Stack underflow":Exit Function
top = top - 1
Pop = True
End Function
Public Function GetTop()
If IsEmpty Then Err.Raise 2,"Stack is empty":Exit Function
GetTop = arrayStack(top)
End Function
Public Function Count()
Count = top
End Function
End Class
%>
ASP的栈类
最新推荐文章于 2024-06-02 20:18:58 发布