Class PriorityQueue<T>Internal

Priority queue.

Type Parameters

  • T

    Type of priority queue data.

Constructors

  • Constructs a priority queue.

    Type Parameters

    • T

    Parameters

    • bucketSize: number = defaultBucketSize

      Prioritized bucket size.

    • enablePriority: boolean = false

      Whether to enable priority.

    Returns PriorityQueue<T>

    PriorityQueue.

    defaultBucketSize
    
    false
    

Properties

maxSize: number

The priority queue maximum size.

Accessors

  • get buckets(): number
  • The number of filled prioritized buckets.

    Returns number

    The number of filled prioritized buckets.

  • get enablePriority(): boolean
  • Whether priority is enabled.

    Returns boolean

    Whether priority is enabled.

  • set enablePriority(enablePriority): void
  • Enables/disables priority.

    Parameters

    • enablePriority: boolean

      Whether to enable priority.

    Returns void

Methods

  • Dequeue data from the priority queue.

    Parameters

    • Optionalbucket: number

      The prioritized bucket to dequeue from.

    Returns undefined | T

    The dequeued data or undefined if the priority queue is empty.

  • Enqueue data into the priority queue.

    Parameters

    • data: T

      Data to enqueue.

    • Optionalpriority: number

      Priority of the data. Lower values have higher priority.

    Returns number

    The new size of the priority queue.