Skip to Main Content
C# Cookbook, 2nd Edition
book

C# Cookbook, 2nd Edition

by Jay Hilyard, Stephen Teilhet
January 2006
Intermediate to advanced content levelIntermediate to advanced
1184 pages
43h 23m
English
O'Reilly Media, Inc.
Content preview from C# Cookbook, 2nd Edition
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
608
|
Chapter 11: Data Structures and Algorithms
The PriorityQueue<T> can be instantiated and filled with strings using code like the
Test class shown in Example 11-2.
DequeueLargest method Returns and removes the item at the tail of the queue (i.e., the last item in the queue).
DequeueSmallest
method
Returns and removes the item at the head of the queue (i.e., the first item in the queue).
PeekSmallest method Returns the item at the head of the queue (i.e., the first item in the queue).
PeekLargest method Returns the item at the tail of the queue (i.e., the last item in the queue).
GetEnumerator method Returns an enumerator that allows iteration of the items in the queue. Calls the
internalQueue method.
Example 11-2. Testing the PriorityQueue class
class Test
{
static void Main( )
{
// Create ArrayList of messages.
List<string> msgs = new List<string>( );
msgs.Add("foo");
msgs.Add("This is a longer message.");
msgs.Add("bar");
msgs.Add(@"Message with odd characters
!@#$%^&*( )_+=-0987654321~|}{[]\\;:?/>.<,");
msgs.Add(@"<
>");
msgs.Add("<text>one</text><text>two</text><text>three</text>" +
"<text>four</text>");
msgs.Add("");
msgs.Add("1234567890");
// Create a Priority Queue with the appropriate comparer.
// The comparer is created from the CompareLen type
// defined in the Discussion ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Stephen Teilhet, Jay Hilyard
C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 0596100639Supplemental ContentCatalog PageErrata