15.02.2015 Views

C# 4 and .NET 4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

linked list ❘ 243<br />

LinkedList<br />

Six<br />

9<br />

One<br />

8<br />

List<br />

9<br />

8<br />

7<br />

6<br />

5<br />

4<br />

3<br />

2<br />

1<br />

0<br />

Four<br />

8<br />

Three<br />

4<br />

Two<br />

3<br />

Five<br />

1<br />

Seven<br />

1<br />

Eight<br />

1<br />

figure 10-4<br />

The heart of the solution is the PriorityDocumentManager class. This class is very easy to use. With the<br />

public interface of this class, new Document elements can be added to the linked list, the first document can<br />

be retrieved, <strong>and</strong> for testing purposes it also has a method to display all elements of the collection as they<br />

are linked in the list.<br />

The class PriorityDocumentManager contains two collections. The collection of type<br />

LinkedList contains all documents. The collection of type List contains references of up to 10 elements that are entry points for adding new documents<br />

with a specific priority. Both collection variables are initialized with the constructor of the class<br />

PriorityDocumentManager. The list collection is also initialized with null:<br />

public class PriorityDocumentManager<br />

{<br />

private readonly LinkedList documentList;<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!