⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 queue.cls

📁 关于图的算法
💻 CLS
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Queue"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'******************************************************************
'这个类要在工程->引用中把Microsoft Scripting Runtime
'选中并调整出来,这样引用才行
'无论是Dictionary还是Collection,在执行效率上要比基于ReDim
'自己编写顺序表要好的多,这些对象提供的功能,在大多情况下也足够了!
'输入“Q.”后自己找下这两个对象的功能!
'基于这种现成的对象,编写一个队列就成为很容易的事情了
'******************************************************************
Private Q As Collection
Private Sub Class_Initialize()
Set Q = New Collection
End Sub
Public Function GetQueueLength() As Integer
    GetQueueLength = Q.Count  '返回表长度
End Function
Public Sub Append(ByVal s As Integer)
    Q.Add s                   '集对象的Add方法就是Append
End Sub
Public Function GetHead() As Integer
    GetHead = Q.Item(1)       '总是返回第一个元素!
    Q.Remove (1)              '总是删除第一个元素!哈哈!一个队列就这么简单
End Function
Public Function IsQueueEmpty() As Boolean
    If Q.Count = 0 Then
        IsQueueEmpty = True
    Else
        IsQueueEmpty = False
    End If
End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -