PriorityQueue

class PriorityQueue<E : Any, Comparable<E>>(capacity: Int)

Priority queue implementation.

Parameters

E

Element that implemented Comparable interface.

capacity

Initial capacity.

Constructors

Link copied to clipboard
constructor(capacity: Int)

Creates a priority queue with the specified capacity.

Functions

Link copied to clipboard
fun clear()

Removes all elements from the queue.

Link copied to clipboard

Returns true if the queue is empty.

Link copied to clipboard
Link copied to clipboard
fun peek(): E?

Returns the element with the highest priority.

Link copied to clipboard
fun pop(): E?

Removes the element with the highest priority.

Link copied to clipboard
fun push(element: E)

Adds the specified element to the queue.

Link copied to clipboard
fun remove(element: E): Boolean

Removes the specified element from the queue.