UNPKG

@cedoor/nfa

Version:

TypeScript implementation of some network flow algorithms.

38 lines (37 loc) 1.11 kB
/** * The queue data structure allows you to perform FIFO * operations in constant time. You can enqueue, dequeue * and peek an item, and get the size of the queue. * JavaScript arrays have 'shift' and * 'push' methods but 'shift' take O(n) time. */ export default class Queue { private front; private end; private store; constructor(); /** * Adds an item to the end of the queue. * Time complexity: O(1). * @param {any} The value to store. */ enqueue(value: any): void; /** * Removes an item from the queue and return its value. * Time complexity: O(1). * @return {any | undefined} The value stored in item. */ dequeue(): any | undefined; /** * Returns the current size of the queue. * Time complexity: O(1). * @return {number} Size of the queue. */ size(): number; /** * Returns the item at front of the queue without dequeuing. * Time complexity: O(1). * @return {any | undefined} The value stored in the item. */ peek(): any | undefined; }