0 Replies - 930 Views - Last Post: 07 August 2007 - 04:39 PM

#1 Chubber  Icon User is offline

  • D.I.C Head
  • member icon

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

FIFO Class

Posted 07 August 2007 - 04:39 PM

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

     Private m_dict
     Private m_lngInKey
     Private m_lngOutKey

     Private Sub Class_Initialize()
          Set m_dict = Server.CreateObject("Scripting.Dictionary")
          m_lngInKey = CLng(-2147483648)
          m_lngOutKey = CLng(-2147483648)
     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_lngOutKey)) Then
               Set Pop = m_dict(m_lngOutKey)
          Else Pop = m_dict(m_lngOutKey)
          End If
          m_dict.Remove m_lngOutKey
          If m_dict.Count = 0 Then
               m_lngInKey = CLng(-2147483648)
               m_lngOutKey = CLng(-2147483648)
          Else m_lngOutKey = CLng(m_lngOutKey + 1)
          End If
     End Function

     Public Sub Push(var)
          m_dict.Add m_lngInKey, var
          m_lngInKey = CLng(m_lngInKey + 1)
     End Sub

End Class



Is This A Good Question/Topic? 0
  • +

Page 1 of 1