30.07.2013 Views

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

Visual Basic.NET How to Program (PDF)

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 23 Data Structures and Collections 1159<br />

32<br />

33 ' use method Dequeue <strong>to</strong> remove items from queue<br />

34 Dim removedObject As Object = Nothing<br />

35<br />

36 ' remove items from queue<br />

37 Try<br />

38<br />

39 ' dequeue item and output removed item<br />

40 While True<br />

41 removedObject = queue.Dequeue()<br />

42 Console.WriteLine(removedObject & " dequeue")<br />

43 queue.Print()<br />

44 End While<br />

45<br />

46 ' if exception occurs, print stack trace<br />

47 Catch emptyListException As EmptyListException<br />

48 Console.Error.WriteLine(emptyListException.StackTrace)<br />

49 End Try<br />

50<br />

51 End Sub ' Main<br />

52<br />

53 End Module ' modQueueTest<br />

The queue is: True<br />

The queue is: True $<br />

The queue is: True $ 34567<br />

The queue is: True $ 34567 hello<br />

True dequeue<br />

The queue is: $ 34567 hello<br />

$ dequeue<br />

The queue is: 34567 hello<br />

34567 dequeue<br />

The queue is: hello<br />

hello dequeue<br />

Empty queue<br />

at LinkedListLibrary.CList.RemoveFromFront() in<br />

C:\books\2001\vbhtp2\ch23\Examples\Fig23_04\LinkedListLibrary\List.vb:line<br />

64<br />

at QueueInheritanceLibrary.CQueueInheritance.Dequeue() in<br />

C:\books\2001\vbhtp2\ch23\Examples\Fig23_15\QueueInheritanceLibrary\QueueInheritance.vb:line<br />

25<br />

at QueueTest.modQueueInheritanceTest.Main() in<br />

C:\books\2001\vbhtp2\ch23\Examples\Fig23_16\QueueTest\QueueTest.vb:<br />

line 41<br />

Fig. 23.16 Queue-by-inheritance test (part 2 of 2).

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

Saved successfully!

Ooh no, something went wrong!