Skip to content

Latest commit

 

History

History
31 lines (16 loc) · 1.28 KB

PriorityQueue.md

File metadata and controls

31 lines (16 loc) · 1.28 KB

PriorityQueue

Represents a Queue in which the elements are ordered using a specified priority.


Constructors

PriorityQueue() Initializes a new instance of PriorityQueue which is empty and ordered by ascending priority value (higher priority first).

PriorityQueue(PriorityQueueOrder order) Initializes a new instance of PriorityQueue which is empty and ordered by ascending or descending priority value.

PriorityQueue(int capacity, PriorityQueueOrder order) Initializes a new instance of PriorityQueue which is ordered by ascending or descending priority value and has the specified initial capacity.


Properties

int Count Gets the number of elements contained in the PriorityQueue.

bool IsEmpty Determines whether the PriorityQueue is empty.


Methods

void Push(T value, int priority) Inserts a new item into the PriorityQueue, in a position relative to the given priority. Complexity: O(LogN)

PriorityQueueNode<T> Pop() Removes the element with the highest (or lowest) priority from the PriorityQueue and returns its value. Complexity: O(LogN)

PriorityQueueNode<T> Peek() Returns the PriorityQueueNode with the highest (or lowest) priority in the PriorityQueue wihout removing it. Complexity: O(1)