Queue<T>
Guide: /guide/data-structures/queue
Generic Types
T - type of collection elements
Implements interfaces
ILinearStorage
Methods
constructor(capacity?: number): Queue<T>
Creates empty instance
Params:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| capacity | number | - | Number.MAX_VALUE | Max capacity of queue (> 0) |
peek(): T
Returns value from top of queue
Throws: CollectionIsEmptyException when queue is empty
pop(): T
Returns value from top of queue and removes it
Throws: CollectionIsEmptyException when queue is empty
push(value: T): void
Add value to top of queue
Params:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| value | T | + | - |
Throws: CollectionIsFullException when there is no space available
has(value: T): boolean
Check is queue has given value
Params:
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| value | T | + | - |
clear(): void
Remove all elements from queue
isEmpty(): boolean
Check is queue has any value, returns true if queue is empty
isFull(): boolean
Check is queue length exceed max capacity
length(): number
Get queue size