<%
'**********************************************
' 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
%>
ASP循环队列类
最新推荐文章于 2018-08-23 22:33:00 发布