Priority queue in Swift

WWDC2021 presentation "Meet the Swift Algorithms and Collections packages" introduced three new collection types.

One collection that I am seriously missing in Swift is a priority queue (a heap). The main operations are:

  • Append an element.
  • Return an element with lowest value (defined by < operator on the elements).
  • Check if an element is already in the queue.
  • Remove an element.

Is a collection like this available in Swift?

Is a collection like this available in Swift?

I do not think so. At lease, not now.

If you want to discuss about some future of Swift, you should better visit swift.org .

You can find Get Involved! part at the bottom of this article. Introducing Swift Collections

Priority queue in Swift
 
 
Q