I use got 2 LinkedListNode P1 and P2 from a LinkedList
I wonder is there a way to know the order of these two.
P1 is behind of P2 or the other way round.
Thanks
Printable View
I use got 2 LinkedListNode P1 and P2 from a LinkedList
I wonder is there a way to know the order of these two.
P1 is behind of P2 or the other way round.
Thanks
Linked Lists! Long time since Ive used one of them!! (ADA95!!)
Anyway,
The whole point of a linked list is that you have the items, linked, in an order. So you can tell the order, as you will have as structure like
RootNode -> Node1 -> Node2
(This is in the most basic linked list environment)
VB Code:
Dim List As New System.Collections.Generic.LinkedList(Of Integer) List.AddAfter(List.AddAfter(List.AddFirst(1), 2), 3) System.Windows.Forms.MessageBox.Show(List.First.Next.Previous.Value.ToString)
This is some simple code that illustrates the point. List.First gets you the first item on the list. From any Node you can then either do a .Previous or .Next