VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Stack"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
'Klasa Stack
Private stk As New Collection

Public Sub push(obj As Object)
  stk.add obj
End Sub

Public Function pop() As Object
  Dim i As Integer
  Dim obj As Object

  i = stk.Count
  If i > 0 Then
    Set obj = stk(i)
    stk.Remove i
  End If
  Set pop = obj
End Function

Public Function top() As ParseObject
  Dim i As Integer
  i = stk.Count
  If i > 0 Then
    Set top = stk(i)
  End If
End Function

Public Function hasMoreElements() As Boolean
  hasMoreElements = (stk.Count > 0)
End Function

Public Function nextTop() As ParseObject
  Dim i As Integer
  i = stk.Count
  If i > 1 Then
    Set nextTop = stk(i - 1)
  Else
    Set nextTop = New DummyObject
  End If
End Function

Public Sub Pop2Push(p As ParseObject)
  Dim i As Integer
  i = stk.Count
  If i > 1 Then
    pop
    pop
    push p
  Else
    push p
  End If
End Sub

Public Function topStack(ByVal c1 As Integer, ByVal c2 As Integer) As Boolean
  Dim pobj1, pobj2 As ParseObject
  
  Set pobj1 = Me.top
  Set pobj2 = Me.nextTop
  topStack = (pobj1.getType() = c1) And (pobj2.getType() = c2)
End Function
