03.01.2015 Views

C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

Visual Studio 2013 C# 5.0 Programmer's Reference

SHOW MORE
SHOW LESS

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

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

Chapter 15 ❘ 675<br />

2. The IncreasingQueue example program does this. The following code shows the<br />

IncreasingQueue class.<br />

public class IncreasingQueue<br />

where T : IComparable<br />

{<br />

// The queue that holds the items.<br />

private Queue Items = new Queue();<br />

// The previously added item.<br />

private T LastValue;<br />

// Constructor.<br />

public IncreasingQueue(T lowerBound)<br />

{<br />

LastValue = lowerBound;<br />

}<br />

// Enqueue.<br />

public void Enqueue(T value)<br />

{<br />

// If this isn't the first item, make sure<br />

// it's bigger than the previous value.<br />

if (value.CompareTo(LastValue)

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

Saved successfully!

Ooh no, something went wrong!