ASP循环队列类

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

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

' File:  CircularQueue.asp

' Version: willpower CircularQueue Class Version 0.1 Build 20080614

' Author: willpower

' Email: wise.willpower@163.com

' QQ:20934440

' Date:  06/14/2008

' Comments: The code for the CircularQueue.

'   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.

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

' 文件名: CircularQueue.asp

' 版本:  willpower CircularQueue Class Version 0.1 Build 20080614

' 作者:  willpower(wise.willpower)

' 电子邮件: wise.willpower@163.com

' QQ:20934440

' 日期:  2008年04月30日

' 声明:  循环队列类

'   本循环队列类可以自由使用,但请保留此版权声明信息

'   如果您对本循环队列类进行修改增强,

'   请发送一份给俺。





Class CircularQueue



Private vMax

Private vIncrement

Private vArrayQueue()

Private vFront

Private vRear

Private vCount



Private Sub Class_Initialize()

Call Initialize()

End Sub



Private Sub Class_Terminate()

Call Terminate()

End Sub



Private Sub Initialize()

vMax = 100

vIncrement = 10

Redim vArrayQueue(increment)

vFront = 1

vRear = 1

vCount = 0

End Sub



Private Sub Terminate()

If IsArray(vArrayQueue) Then Erase vArrayQueue

End Sub





Public Sub InitQueue()

Call Terminate()

Call Initialize()

End Sub



Public Function IsEmpty()

IsEmpty = False

If vCount = 0 Then IsEmpty = True

End Function



Public Function IsFull()

IsFull = False

If vCount < Ubound(vArrayQueue) Then Exit Function

If count < vMax Then Redim Preserve vArrayQueue(vCount + vIncrement):Exit Function

IsFull = True

End Function



Public Function EnQueue(ByVal str)

EnQueue = False

If str = "" Then Err.Raise 3,"String is empty":Exit Function

If IsFull Then Err.Raise 1,"Queue overflow":Exit Function

vArrayQueue(vRear) = str

vRear = (vRear + 1) Mod Ubound(vArrayQueue)

vCount = vCount + 1

EnQueue = True

End Function



Public Function DeQueue()

DeQueue = False

If IsEmpty Then Err.Raise 2,"Queue underflow":Exit Function

vFront = (vFront + 1) Mod Ubound(vArrayQueue)

vCount = vCount - 1

DeQueue = True

End Function



Public Function GetFront()

If IsEmpty Then Err.Raise 2,"Stack is empty":Exit Function

GetFront = vArrayQueue(vFront)

End Function



Public Function Count()

Count = vCount

End Function



End Class



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值