Skip to content

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: ​
NameTypeRequiredDefaultDescription
capacitynumber-Number.MAX_VALUEMax 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: ​
NameTypeRequiredDefaultDescription
valueT+-
Throws: CollectionIsFullException when there is no space available ​



has(value: T): boolean ​

Check is queue has given value

Params: ​
NameTypeRequiredDefaultDescription
valueT+-



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

MIT Licensed