Interface IQueue<T>
Defines the interface common to all Queues implementations for items of type T
.
Namespace: MoreStructures.Queues
Assembly: MoreStructures.dll
Syntax
public interface IQueue<T>
Type Parameters
Name | Description |
---|---|
T | The type of items, the queue is composed of. |
Remarks
DEFINITION
- A Queue is a data structure storing items of a generic type T
in a FIFO (First In
First Out) fashion.
- Items are inserted at the back (or end) of the queue and extracted from the front (or begin) of the queue.
- Like stacks, they are specialized data structures for which general random access is not a priority.
- As for stack, O(1) non amortized cost of insertion and extraction can be provided in some implementations.
- Arrays and array lists can be used as a backing structure for a stack, and still have O(1) amortized
cost within array boundaries and O(1) amortized cost to remove array boundaries constraints.
- Items are in a total order relationship and duplicates are supported.
Properties
| Improve this Doc View SourceCount
The number of items currently in the queue.
Declaration
int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceDequeue()
Pops the item out from the front of the queue and returns it as a result.
Declaration
T Dequeue()
Returns
Type | Description |
---|---|
T | The item of type |
Remarks
The item which was on second position at the front of the queue gets promoted to first position after the item at the front is popped out. The position of all the items is shifted of -1.
Enqueue(T)
Push the provided item
at the back of the queue.
Declaration
void Enqueue(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item of type |
Remarks
All other items in the queue keep their position.
Peek()
Returns the item at the front of the queue, without popping it out from the queue.
Declaration
T Peek()
Returns
Type | Description |
---|---|
T | The item of type |