
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
618
|
Chapter 11: Data Structures and Algorithms
dqueue.Contains(10): False
dqueue.PeekHead( ): 0
dqueue.PeekTail( ): 3
Queued Item (CopyTo): 0
Queued Item (CopyTo): 1
Queued Item (CopyTo): 2
Queued Item (CopyTo): 3
dqueue.DequeueHead( ): 0
dqueue.DequeueTail( ): 3
dqueue.DequeueTail( ): 2
dqueue.Count: 1
Queued Item: 1
Discussion
The DblQueue<T> class implements the same three interfaces as the Queue<T> class
found in the
System.Collections.Generic namespace of the FCL. These are the
ICollection, IEnumerable, and ICloneable interfaces. The IEnumerable interface
forces the
DblQueue<T> to implement the GetEnumerator method. The implementa-
tion of the
DblQueue<T>.GetEnumerator method returns the IEnumerator object for the
internal
List<T>, used to store the queued items.
The
ICollection interface forces three properties and a method to be implemented
by the
DblQueue<T> class. The IsSynchronized property returns false, and the
SyncRoot method returns the DblQueue<T> object on which it was called. These syn-
chronization properties and methods will be discussed at length in Recipes 4.4, 4.10,
and 18.2.
The
ICollection interface also forces the Count property and the CopyTo method to be
implemented by the
DblQueue<T> class. Both of these delegate to the corresponding
List<T> property and method for their implementations. ...