ResizingArrayQueueItem Class |
The ResizingArrayQueue class represents a first-in-first-out (FIFO) queue of generic items. 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 resizing array, which double the underlying array when it is full and halves the underlying array when it is one-quarter full. The Enqueue and Dequeue operations take constant amortized time. The Count, Peek, and IsEmpty operations takes constant time in the worst case.
Namespace: Algs4Net
The ResizingArrayQueueItem type exposes the following members.
Name | Description | |
---|---|---|
![]() | ResizingArrayQueueItem | 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 ResizingArrayQueue data type. |
![]() | Peek |
Returns the item least recently added to this queue. |
For additional documentation, see Section 1.3 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.
This class is a C# port from the original Java class ResizingArrayQueue implementation by the respective authors.