import type { Dictionary } from '@empathyco/x-utils'; import type { NumberComparatorFn, XPriorityQueue, XPriorityQueueNode } from './x-priority-queue.types'; /** * Default {@link XPriorityQueueNode} implementation. * * @public */ export declare class BaseXPriorityQueueNode implements XPriorityQueueNode { readonly key: keyof SomeRecord; readonly priority: number; readonly data: SomeData; constructor(key: keyof SomeRecord, priority: number, data?: SomeData); /** * Returns a string representation of this object. The string representation consists of: its * priority, enclosed in square brackets (`[]`), followed by its key, an arrow `(->)` and the * data converted to a string using JSON.stringify. * * @example * ``` * [10] 1 -> { replaceable: false, randomKey: randomValue } * ``` * * @returns A string representation of this object. * * @public */ toString(): string; } /**. * Default {@link XPriorityQueue} implementation. * * Method big-O * --------------------------- * - push O(n) * - pop O(1) * - peek O(1) * - at O(1) * * @public */ export declare class BaseXPriorityQueue implements XPriorityQueue { /** * The list of stored {@link XPriorityQueueNode | nodes}. * * @internal */ protected nodes: XPriorityQueueNode[]; /** * The comparator function to use for sorting. * * @internal */ protected comparatorFn: NumberComparatorFn; /** * Creates a new {@link XPriorityQueue}. * * @param comparatorFn - Comparator - the comparator that will be used to order this queue. * By default, the elements will be sorted in descending order (an element with priority 1 will * be higher in the queue than another with priority 0). */ constructor(comparatorFn?: NumberComparatorFn); /** * The `keys` property of a {@link XPriorityQueue} represents the keys of that queue. The value is * an array of the parametrized `Key` type. * * @returns The list of keys. */ get keys(): (keyof SomeRecord)[]; /**. * See {@link XPriorityQueue.push}. * * @remarks * If the optional data has a 'replaceable: true' and a similar key is already in the queue, * the previous key will be removed and the new one will be inserted to the queue at the * correct position based on its new priority. * * @param key - The key to insert. * @param priority - The priority to order the element in the queue. * @param data - The extra data associated to a key and priority pair. */ push(key: keyof SomeRecord, priority: number, data?: SomeData): void; /** * Inserts the node into the queue in the correct position based on the comparator function. * * @param newNode - The node to be inserted. * * @internal */ private pushAndSort; /** * See {@link XPriorityQueue.pop}. * * @returns The head {@link XPriorityQueueNode | node} of the queue or undefined if it is empty. */ pop(): XPriorityQueueNode | undefined; /** * Retrieves, but does not remove, the head {@link XPriorityQueueNode | node} of the queue. * * @returns The head {@link XPriorityQueueNode | node} of the queue. */ peek(): XPriorityQueueNode | undefined; /** * Retrieves the {@link XPriorityQueueNode | node} at a given position. * * @param index - The position to look at. * * @returns The {@link XPriorityQueueNode | node} at the passed position in the queue. */ at(index: number): XPriorityQueueNode | undefined; /** * Removes all the {@link XPriorityQueueNode | nodes} from the queue. */ clear(): void; /** * Checks if the queue is empty. * * @returns True if the queue is empty, false otherwise. */ isEmpty(): boolean; /** * Retrieves the number of {@link XPriorityQueueNode | nodes} stored in the queue. * * @returns The number of {@link XPriorityQueueNode | nodes} stored in the queue. */ size(): number; /** * Returns a string representation of this collection. The string representation consists of a * list of the queue {@link XPriorityQueueNode | nodes} split in multiple lines, one for each * one. Nodes are converted to strings as by toString(). * * @example * ``` * [10] 1 -> { replaceable: false, a: 'b' } * [20] 2 -> { replaceable: false } * [30] 3 -> { replaceable: false, c: 1 } * ``` * * @returns A string representation of the queue. */ toString(): string; } //# sourceMappingURL=x-priority-queue.d.ts.map