Click or drag to resize
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.

Inheritance Hierarchy
SystemObject
  Algs4NetResizingArrayQueueItem

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class ResizingArrayQueue<Item> : IEnumerable<Item>, 
	IEnumerable

Type Parameters

Item

The ResizingArrayQueueItem type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyCount
Returns the number of items in this queue.
Public propertyIsEmpty
Is this queue empty?
Top
Methods
  NameDescription
Public methodDequeue
Removes and returns the item on this queue that was least recently added.
Public methodEnqueue
Adds the item to this queue.
Public methodGetEnumerator
Returns an iterator that iterates over the items in this queue in FIFO order.
Public methodStatic memberMainTest
Demo test the ResizingArrayQueue data type.
Public methodPeek
Returns the item least recently added to this queue.
Top
Remarks

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.

See Also