<!--#include file="Array.Class.asp"--> <% Class WeakList '********* MEMBER VARIABLES ********** Private dynArray '************************************* '********* EVENT HANDLERS ************ Private Sub Class_Initialize() 'Allocate the dynamic array instance Set dynArray = New DynamicArray End Sub Private Sub Class_Terminate() Set dynArray = Nothing 'Clean up! End Sub '************************************* '************ PROPERTIES ************* Public Property Get Count() Count = dynArray.StopIndex() - dynArray.StartIndex() End Property '************************************* '************* METHODS *************** Public Sub AddHead(varItem) 'Add an element to the start of the arrray 'Start by moving all of the elements down on position Dim iLoop For iLoop = dynArray.StopIndex() to dynArray.StartIndex() STEP -1 dynArray.Data(iLoop + 1) = dynArray.Data(iLoop) Next 'Insert varItem at the head dynArray.Data(dynArray.StartIndex()) = varItem End Sub Public Function RemoveHead() 'Remove and return the element from the start of the array 'Don't do this if StopIndex() < StartIndex() If dynArray.StopIndex() > dynArray.StartIndex() then RemoveHead = dynArray.Data(dynArray.StartIndex()) dynArray.Delete(dynArray.StartIndex()) End If End Function Public Sub AddTail(varItem) 'Add an element to the end of the array dynArray.Data(dynArray.StopIndex()) = varItem End Sub Public Function RemoveTail() 'Remove and return the element from the end of the array 'Don't do this if StopIndex() < StartIndex() If dynArray.StopIndex() > dynArray.StartIndex() then RemoveTail = dynArray.Data(dynArray.StopIndex() - 1) dynArray.Delete(dynArray.StopIndex() - 1) End If End Function Public Function PeekHead() 'Return the element at the head of the array 'Don't do this if StopIndex() < StartIndex() If dynArray.StopIndex() > dynArray.StartIndex() then PeekHead = dynArray.Data(dynArray.StartIndex()) End If End Function Public Function PeekTail() 'Return the element at the end of the array 'Don't do this if StopIndex() < StartIndex() If dynArray.StopIndex() > dynArray.StartIndex() then PeekTail = dynArray.Data(dynArray.StopIndex() - 1) End If End Function '************************************* End Class %>