Priority Queue

Hey All,

I am currently doing some coding challenges, I feel like there is a gap between Swift and other languages as I think we do not have a heapq (python) or PriorityQueue (Java) replacement to undertake Djistras.

Is there some alternative and if not is this something we can add?

Some more comments:

  • I don't know if you can import swift-algorithms or some other package in the middle of an interview.
  • Also want to acknowledge that it might be useful to know how to implement one on my own, but sometimes thats not the point of the coding problem.

Context:
Trying to solve the below problem using Swift. Immediate thought is this is a Djistras between the start and end node. But implementing Djistras in swift is not straightforward to me.

https://leetcode.com/problems/network-delay-time/

I have seen this in SwiftNIO, wondering if we can copy this across so it is accessible by all.

EDIT: swift-collections/Documentation/Heap.md at main · apple/swift-collections · GitHub
Seems to partially exist in swift-collections

You can find a min-max heap implementation in swift-collections: swift-collections/Documentation/Heap.md at main · apple/swift-collections · GitHub

Ahh yeah, I edited my first reply to point to that example. I can see here that

Similar to packages like Swift Numerics and Swift Algorithms, an important goal of the Collections package is to serve as a (relatively) low-friction proving ground for new data structure implementations, before they become ready to be proposed as official library additions through the regular Swift Evolution process.

Are we waiting on someone to propose the Heap object or the Priority queue be added to the main swift library? I mentioned this in my original post, but I don't think I can import a package into leet code or the equivalent coding interview platforms.