0
Is linked is tougher or easier?
how to make it easy
2 odpowiedzi
+ 1
For beginners I would not say LinkedList is easier, requires more on the handling than simply Lists and arrays. While you can use foreach loop for the last two mentioned, LinkedList handled more in a manual way.
Instead of .Add() there are .AddFirst() and .AddLast() methods. The first adds the element to the beginning of the list/chain, the second puts it onto its end, like List.Add() does.
Rolling thru its elements is toughter a bit:
LinkedList<Type> list = new LinkedList<Type>();
... add elements ...
LinkedListNode<Type> node = list.First;
while (node != null) {
... use node ...
node = node.Next;
}
Or backwards:
LinkedListNode node = list.Last;
while (node != null) {
... use node ...
node = node.Previous;
}
0
thank you