All pastes #258253 Raw Edit

sss

public text v1 · immutable
#258253 ·published 2006-11-26 09:40 UTC
rendered paste body
Public Function FindNode(ByVal value As t) As RawrNode(Of t)

        If FirstNode Is Nothing Then Return Nothing

        If ListDebug Then Debug.Print("Starting find node...")

        Dim n As RawrNode(Of t) = FirstNode
        Dim c As Integer
        Do
            c += 1
            If ListDebug Then Debug.Print("(" + c.ToString + "/" + Count.ToString + ") Examining node " + n.OID)

            'This next line is the problem,  because only 'Is' is defined for
            't (which could be ANY type), but I need to use '=' if i'm dealing
            'with strings because i want to compare the value, and not the
            'reference to the value.  I can't use = for type t, and it wont
            'let me convert type t to type string using either CType(), 
            'DirectCast() or TryCast().

            If n.Value Is value Then
                If ListDebug Then Debug.Print("found node.  exiting")
                Return n
            End If
            If n.NextNode Is Nothing Then
                If ListDebug Then Debug.Print("no more nodes.. exiting")
                Return Nothing
            End If
            n = n.NextNode
        Loop
        Debug.Print("abnormal findnode exit")
    End Function