vbAccelerator - Contents of code file: cStackLinkedObject.cls

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

' cStackLinkedObject
' SPM- simple class to manage a stack from
' linked objects

Implements IStack

Private m_cStackTop As cStackLinkedObjectItem
Private m_iCount As Long


Private Sub Class_Terminate()
   Do While m_iCount
      IStack_Pop
   Loop
End Sub

Private Property Get IStack_Count() As Long
   IStack_Count = m_iCount
End Property

Private Function IStack_Pop() As String

   If m_iCount Then
      IStack_Pop = m_cStackTop.Item
      Dim cTemp As cStackLinkedObjectItem
      Set cTemp = m_cStackTop.NextLink
      Set m_cStackTop = Nothing
      If Not cTemp Is Nothing Then
         Set m_cStackTop = cTemp
      End If
      m_iCount = m_iCount - 1
   End If
End Function

Private Sub IStack_Push(sArg As String)
   
   Dim cTemp As cStackLinkedObjectItem
   Set cTemp = m_cStackTop
   
   Set m_cStackTop = New cStackLinkedObjectItem
   m_cStackTop.Item = sArg

   If Not cTemp Is Nothing Then
      m_cStackTop.NextLink = cTemp
   End If
   
   m_iCount = m_iCount + 1

End Sub