LinkedQueueItem Class |
The LinkedQueue class represents a first-in-first-out (FIFO) queue of generic items. So named to avoid conflict with the .NET framwork QueueT class. Since C# does not allow an inner static class with instances, the implementation is effectively the same as the Queue class implementation.
It supports the usual Enqueue and Dequeue operations, along with methods for peeking at the first item, testing if the queue is empty, and iterating through the items in FIFO order.
This implementation uses a singly-linked list with a nested, non-static class Node and hence is the same as the Queue class in algs4.jar. The Enqueue, Dequeue, Peek, Count, and IsEmpty operations all take constant time in the worst case.
Namespace: Algs4Net
The LinkedQueueItem type exposes the following members.
Name | Description | |
---|---|---|
![]() | LinkedQueueItem |
Initializes an empty queue. |
Name | Description | |
---|---|---|
![]() | Dequeue |
Removes and returns the item on this queue that was least recently added. |
![]() | Enqueue | Adds the item to this queue. |
![]() | GetEnumerator |
Returns an iterator that iterates over the items in this queue in FIFO order. |
![]() ![]() | MainTest |
Demo test the LinkedQueue data type. |
![]() | Peek | Returns the item least recently added to this queue. |
![]() | ToString |
Returns a string representation of this queue. (Overrides ObjectToString.) |
This class is a C# port from the original Java class LinkedQueue implementation by Robert Sedgewick and Kevin Wayne.