@typescript-package/queue
Version:
A lightweight TypeScript library for managing various queue and stack structures.
84 lines (83 loc) • 2.09 kB
TypeScript
import { Elements } from "./elements.class";
/**
* @description A standard FIFO (First In, First Out) queue.
* @export
* @abstract
* @class Queue
* @template Type
*/
export declare abstract class Queue<Type, Size extends number = number> {
#private;
/**
* @description The `Elements` state holder.
* @public
* @readonly
* @type {Elements<Type>}
*/
get elements(): Elements<Type>;
/**
* @description The actual queue length.
* @public
* @readonly
* @type {number}
*/
get length(): number;
/**
* @description The maximum queue size.
* @public
* @readonly
* @type {Size}
*/
get size(): Size;
/**
* @description The actual queue `Elements` state - raw `array` state of the queue.
* @public
* @readonly
* @type {readonly Type[]}
*/
get state(): readonly Type[];
/**
* Creates an instance of child class.
* @constructor
* @param {Size} [size=Infinity as Size] The maximum size of the `Queue`.
* @param {...Type[]} elements The arbitrary parameters of elements of `Type` to add.
*/
constructor(size?: Size, ...elements: Type[]);
/**
* @description Clears the queue.
* @public
* @returns {this}
*/
clear(): this;
/**
* @description Removes and returns the first (front) element from the queue.
* @public
* @returns {(Type | undefined)}
*/
dequeue(): Type | undefined;
/**
* @description Adds a new element to the queue.
* @public
* @param {Type} element The element of `Type` to add.
* @returns {this}
*/
enqueue(element: Type): this;
/**
* @description Checks if the queue is empty.
* @public
* @returns {boolean}
*/
isEmpty(): boolean;
/**
* @description Checks if the queue is full.
* @public
* @returns {boolean}
*/
isFull(): boolean;
/**
* @description Returns the first element in the queue.
* @public
* @returns {Type}
*/
peek(): Type;
}