The LinkedList(Of T) Collection

Think of the System.Collections.Generic.LinkedList(Of T) collection as a chain in which each ring is an item in the collection that is linked to the others. In other words, an item is linked to the previous one and the next one and points to them. Each item in the collection is considered as a LinkedListNode(Of T), so if you decide to create a LinkedList(Of Person), each Person instance will be represented by a LinkedListNode(Of Person). Table 16.2 summarizes the most common methods and properties for the collection over the ones that you already know (derived from IList(Of T)).

Table 16.2 LinkedList Members

image

The following code provides an example of creating and consuming a LinkedList(Of Person) collection (see comments for explanations):

image

The most important difference between this collection and the other ones is that items are linked. This is demonstrated by an Enumerator structure exposed by every instance of the collection that enables moving between items, as demonstrated in the following code snippet:

image

This code basically demonstrates that items in the collections are linked and that each one points to the next one.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.239.111