Part 2
Dynamic Data Structure.
LinkedList<string> linked = new LinkedList<string>();
linked.AddLast("one");
linked.AddLast("two");
linked.AddLast("three");
LinkedListNode<string> node = linked.Find("one");
linked.AddAfter(node, "inserted");
foreach (var value in linked)
{
Console.WriteLine(value);
}
//one
//inserted
//two
//three
LinkedList<string> linked = new LinkedList<string>();
linked.AddLast("one");
linked.AddLast("two");
linked.AddLast("three");
LinkedListNode<string> node = linked.Find("one");
linked.AddBefore(node, "inserted");
foreach (var value in linked)
{
Console.WriteLine(value);
}
//one
//inserted
//two
//three
Removing Operation.
sentence.Remove("old");
Display(sentence, "Test 14: Remove node that has the value 'old':");
//Test 14: Remove node that has the value 'old':
//the quick brown dog jumped over the lazy fox
ToArray Operation.
string[] sArray = new string[sentence.Count];
sentence.CopyTo(sArray, 0);
//Test 16: Copy the list to an array:
//the
//quick
//brown
//dog
//jumped
//over
//the
//lazy
//rhinoceros