gis-tools-ts - v0.6.0
    Preparing search index...

    Class PriorityQueue<T>

    Priority Queue

    A priority queue is a data structure that stores elements in a specific order.

    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

    Type Parameters

    • T = number
    Index

    Constructors

    Accessors

    Methods

    Constructors

    Accessors

    • get length(): number

      Returns number

      • the number of items

    Methods

    • Peek at the top item without removing it

      Returns undefined | T

      • the top item
    • Access the top item, remove it, and return it

      Returns undefined | T

      • the top item
    • Push an item into the queue

      Parameters

      • item: T

        the item to store

      Returns void