vbAccelerator - Contents of code file: cStackCollection.cls

VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "cStackCollection"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

' cStackCollection
' Bruce McKinney from Hardcore Visual Basic
' modified SPM to use collection key rather than index
' - key is always much quicker than index


Implements IStack

' Use a collection
Private ocolStack As Collection


Private Sub Class_Initialize()
   Set ocolStack = New Collection
End Sub

Private Sub Class_Terminate()
   Set ocolStack = Nothing
End Sub

Private Property Get IStack_Count() As Long
   IStack_Count = ocolStack.Count
End Property

Private Function IStack_Pop() As String
   If ocolStack.Count Then
      IStack_Pop = ocolStack("C" & ocolStack.Count)
      ocolStack.Remove "C" & ocolStack.Count
   End If
End Function

Private Sub IStack_Push(sArg As String)
   ocolStack.Add sArg, "C" & ocolStack.Count + 1
End Sub