vbAccelerator - Contents of code file: cStackArray.cls
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "cStackArray"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
' cStackArray
' Bruce McKinney from Hardcore Visual Basic
' Modified SPM - remove error handler
Implements IStack
Private m_s() As String
Private Const cChunk = 10
Private m_iLast As Long, m_iCur As Long
Private Property Get IStack_Count() As Long
IStack_Count = m_iCur
End Property
Private Function IStack_Pop() As String
If m_iCur Then
IStack_Pop = m_s(m_iCur)
m_iCur = m_iCur - 1
If m_iCur < (m_iLast - cChunk) Then
' shrink:
m_iLast = m_iLast - cChunk
ReDim Preserve m_s(1 To m_iLast) As String
End If
End If
End Function
Private Sub IStack_Push(sArg As String)
m_iCur = m_iCur + 1
If m_iCur > m_iLast Then
' Grow:
m_iLast = m_iLast + cChunk
ReDim Preserve m_s(1 To m_iLast) As String
End If
m_s(m_iCur) = sArg
End Sub
|
|