Module: structs/PriorityQueue

structs/PriorityQueue

new require("structs/PriorityQueue")()

This:
  • {PriorityQueue}
Source:
A priority queue data structure.
Source:
See:

Classes

require("structs/PriorityQueue")

Methods

dequeue() → {Object}

Get and remove the element with the highest priority.
This:
  • {PriorityQueue}
Source:
Returns:
The element with highest priority. Also removes it from the queue. If the `size()` is 0, null is returned instead.
Type
Object

enqueue(priority, data)

Add an element to the queue.
This:
  • {PriorityQueue}
Parameters:
Name Type Description
priority Number The priority of the element.
data Object The data that should be stored.
Source:

peek() → {Object}

Get the element with the highest priority without removing it.
This:
  • {PriorityQueue}
Source:
Returns:
The element with highest priority and don't remove it. If the `size()` is 0, null is returned instead.
Type
Object

size() → {Number}

The number of elements in the queue.
This:
  • {PriorityQueue}
Source:
Returns:
Type
Number