PriorityQueue
Undocumented
-
A comparison function.
Should return true if the lhs is higher priority than the rhs, so that true means lhs will be extracted before rhs.
Should return true if the two arguments have the same priority.
Declaration
Swift
var compare: (Element, Element) -> Bool { get }
-
Initialize an empty queue over the given comparison function.
Declaration
Swift
init(compare: (Element, Element) -> Bool)
Parameters
compare
A function that compares two elements of the queue.
-
Insert a new element into the priority queue.
Declaration
Swift
mutating func insert(item: Element)
Parameters
item
the item to insert.
-
Get the element of highest priority, without changing the queue.
Declaration
Swift
func peek() -> Element?
Return Value
The element of highest priority, or nil if queue is empty.
-
Get and remove the element of highest priority. Changes the queue.
Declaration
Swift
mutating func extract() -> Element?
Return Value
The element of highest priority, or nil if queue is empty. This element is removed if it exists.