0 Replies - 933 Views - Last Post: 07 August 2007 - 04:40 PM

#1 Chubber  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 131
  • Joined: 16-October 06

LifO Class

Posted 07 August 2007 - 04:40 PM

Description: A simple Last In/First Out storage object.
'-----------------------------------------------------------
' LifO Class
' -----------
'     A simple Last In/First Out storage object.
Class LifO

     Private m_dict

     Private Sub Class_Initialize()
          Set m_dict = Server.CreateObject("Scripting.Dictionary")
     End Sub

     Private Sub Class_Terminate()
          Set m_dict = Nothing
     End Sub

     Public Property Get Count()
          Count = m_dict.Count
     End Property

     Public Function Pop()
          If m_dict.Count = 0 Then Exit Function
          If IsObject(m_dict(m_dict.Count)) Then
               Set Pop = m_dict(m_dict.Count)
          Else Pop = m_dict(m_dict.Count)
          End If
          m_dict.Remove m_dict.Count
     End Function

     Public Sub Push(var)
          Dim lngNewKey
          lngNewKey = m_dict.Count + 1
          m_dict.Add lngNewKey, var
     End Sub

End Class


Is This A Good Question/Topic? 0
  • +

Page 1 of 1