ASP的栈类
来源:互联网 发布:数据芯片多少钱 编辑:程序博客网 时间:2024/06/06 07:47
<%'**********************************************' 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 StackPrivate maxPrivate incrementPrivate arrayStack()Private topPrivate Sub Class_Initialize()Call Initialize()End SubPrivate Sub Class_Terminate()Call Terminate()End SubPrivate Sub Initialize()max = 100increment = 10Redim arrayStack(increment)top = 0End SubPrivate Sub Terminate()If IsArray(arrayStack) Then Erase arrayStackEnd SubPublic Sub InitStack()Call Terminate()Call Initialize()End SubPublic Function IsEmpty()IsEmpty = FalseIf top = 0 Then IsEmpty = TrueEnd FunctionPublic Function IsFull()IsFull = FalseIf top < Ubound(arrayStack) Then Exit FunctionIf top < max Then Redim Preserve arrayStack(top + increment):Exit FunctionIsFull = TrueEnd FunctionPublic Function Push(ByVal str)Push = FalseIf str = "" Then Err.Raise 3,"String is empty":Exit FunctionIf IsFull Then Err.Raise 1,"Stack overflow":Exit Functiontop = top + 1arrayStack(top) = strPush = TrueEnd FunctionPublic Function Pop()Pop = FalseIf IsEmpty Then Err.Raise 2,"Stack underflow":Exit Functiontop = top - 1Pop = TrueEnd FunctionPublic Function GetTop()If IsEmpty Then Err.Raise 2,"Stack is empty":Exit FunctionGetTop = arrayStack(top)End FunctionPublic Function Count()Count = topEnd FunctionEnd Class%>