A couple of list methods that I have used.. since Monkey seemed to be missing these I made my own List module, and added these two into the List class.
Method AddBefore:Node<T>(value:T, valueAfter:T)
Local nodeOfValueAfter:Node<T> = Find(valueAfter)
If nodeOfValueAfter = Null
Return AddLast(value)
End
Return New Node<T>(nodeOfValueAfter, nodeOfValueAfter._pred, value)
End
Method Find:Node<T>(dataToFind:T)
Local node:=_head._succ
While node<>_head
node=node._succ
If Equals( node._pred._data,dataToFind ) Return node._pred
Wend
Return Null
End
|