Queue
Creates a new queue. A queue is a first-in-first-out (FIFO) data structure - items are added to the end of the queue and removed from the front.
Constructor Summary
| Public Constructor | ||
| public |
Constructs a Queue instance. |
|
Member Summary
| Public Members | ||
| public |
|
|
| public |
queue: * |
|
| public get |
Getter for size, allows access as a property). |
|
Method Summary
| Public Methods | ||
| public |
clear() Clear the queue. |
|
| public |
dequeue(): * Dequeues an item and returns it. |
|
| public |
enqueue(item: *) Enqueues the specified item. |
|
| public |
Helper function to loop through all items in the queue. |
|
| public |
Check if the queue contains the specified item. |
|
| public |
peek(): * Returns the item at the front of the queue (without dequeuing it). |
|
Public Constructors
Public Members
public queue: * source
Public Methods
public dequeue(): * source
Dequeues an item and returns it. If the queue is empty, the value null is returned.
Return:
| * (nullable: true) | The next item in the queue, or null if the queue is empty. |
public enqueue(item: *) source
Enqueues the specified item.
Params:
| Name | Type | Attribute | Description |
| item | * | the item to enqueue |
public forEach(callback: function(item: *): boolean) source
Helper function to loop through all items in the queue.
public has(item: *): boolean source
Check if the queue contains the specified item.
Params:
| Name | Type | Attribute | Description |
| item | * | Item to check. |
Throw:
Throws an error if checking null or undefined. |
public peek(): * source
Returns the item at the front of the queue (without dequeuing it). If the queue is empty then null is returned.
Return:
| * (nullable: true) | The next item in the queue, or null if the queue is empty. |