0.0.9 • Published 2 years ago

@types/js-priority-queue v0.0.9

Weekly downloads
255
License
MIT
Repository
github
Last release
2 years ago

Installation

npm install --save @types/js-priority-queue

Summary

This package contains type definitions for js-priority-queue (https://github.com/adamhooper/js-priority-queue).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/js-priority-queue.

index.d.ts

// Type definitions for js-priority-queue
// Project: https://github.com/adamhooper/js-priority-queue
// Definitions by: York Yao <https://github.com/plantain-00/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/* =================== USAGE ===================
    import * as PriorityQueue from "js-priority-queue";
    var queue = new PriorityQueue<number>({ comparator: (a, b) => b - a });
    queue.queue(5);
 =============================================== */

declare module "js-priority-queue" {
    class AbstractPriorityQueue<T> {
        /**
         * Returns the number of elements in the queue
         */
        public length: number;
        /**
         * Creates a priority queue
         */
        constructor(options?: PriorityQueue.PriorityQueueOptions<T>);
        /**
         * Inserts a new value in the queue
         */
        public queue(value: T): void;
        /**
         * Returns the smallest item in the queue and leaves the queue unchanged
         */
        public peek(): T;
        /**
         * Returns the smallest item in the queue and removes it from the queue
         */
        public dequeue(): T;
        /**
         * Removes all values from the queue
         */
        public clear(): void;
    }
    namespace PriorityQueue {
        type PriorityQueueOptions<T> = {
            /**
             * This is the argument we would pass to Array.prototype.sort
             */
            comparator?: ((a: T, b: T) => number) | undefined;
            /**
             * You can also pass initial values, in any order.
             * With lots of values, it's faster to load them all at once than one at a time.
             */
            initialValues?: T[] | undefined;
            /**
             * According to JsPerf, the fastest strategy for most cases is BinaryHeapStrategy.
             * Only use ArrayStrategy only if you're queuing items in a very particular order.
             * Don't use BHeapStrategy, except as a lesson in how sometimes miracles in one programming language aren't great in other languages.
             */
            strategy?: typeof AbstractPriorityQueue | undefined;
        }
        class ArrayStrategy<T> extends AbstractPriorityQueue<T>{ }
        class BinaryHeapStrategy<T> extends AbstractPriorityQueue<T>{ }
        class BHeapStrategy<T> extends AbstractPriorityQueue<T>{ }

    }
    class PriorityQueue<T> extends AbstractPriorityQueue<T> { }
    export = PriorityQueue;
}

Additional Details

  • Last updated: Thu, 08 Jul 2021 16:22:45 GMT
  • Dependencies: none
  • Global values: none

Credits

These definitions were written by York Yao.

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

4 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago