Tip Your own Linked List Class

lolrapa

New member
Joined
Aug 10, 2014
Messages
4
Programming Experience
5-10
I will just leave a simple example of a linked list class.
VB.NET:
Public Class Node   
    Public NextNode As Node
    Public Val As String
End Class

Public Class List
    Public FirstNode As Node

    Public Sub Add(ByVal val As String)
        'Add new node at the beginning of the list
        Dim NewNode As New Node
        If IsNothing(FirstNode) Then
            FirstNode = NewNode
            NewNode.Val = val
        Else
            NewNode.NextNode = FirstNode
            FirstNode = NewNode
            NewNode.Val = val
        End If
    End Sub

    Public Function Read() As List(Of String)
        Dim res As New List(Of String)
        Dim act As Node
        act = FirstNode
        Do Until (IsNothing(act))
            res.Add(act.Val)
            act = act.NextNode
        Loop
        res.Reverse()
        Return res
    End Function
End Class
 
This is not intended as a critique of your class with regards to its implementation but does it really serve a useful purpose, given that there's already a LinkedList(Of T) class in the Framework?
 
I know there is allready a Linked list, but is not the will to learn and share enough purpose? Besides you can create your own linking method and that kind of stuff :) (sorry if there is something written wrong, my laptops screen is cracked and I can't see a thing)
 
Back
Top