ASP的栈类

3 篇文章 0 订阅
2 篇文章 0 订阅
<%

'**********************************************

' 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

%>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值