UNPKG

gis-tools-ts

Version:

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

54 lines 1.36 kB
/** How the comparison function needs to work */ export type PriorityCompare<T> = (a: T, b: T) => number; /** * # Priority Queue * * ## Description * A priority queue is a data structure that stores elements in a specific order. * * ## Usage * * ```ts * import { PriorityQueue } from 'gis-tools-ts'; * * const queue = new PriorityQueue<number>([], (a, b) => a - b); * * queue.push(1); * queue.push(2); * * const current = queue.peek(); // 1 * console.log(queue.length); // 2 * let next = queue.pop(); // 1 * console.log(queue.length); // 1 * next = queue.pop(); // 2 * console.log(queue.length); // 0 * ``` */ export declare class PriorityQueue<T = number> { #private; private data; private compare; /** * @param data - initial data * @param compare - compare function */ constructor(data?: T[], compare?: PriorityCompare<T>); /** @returns - the number of items */ get length(): number; /** * Push an item into the queue * @param item - the item to store */ push(item: T): void; /** * Access the top item, remove it, and return it * @returns - the top item */ pop(): T | undefined; /** * Peek at the top item without removing it * @returns - the top item */ peek(): T | undefined; } //# sourceMappingURL=priorityQueue.d.ts.map