Does Kotlin has a `sorted queue` that I can use for KMP project? Java has `PriorityQueue` but I can’...
l
Does Kotlin has a
sorted queue
that I can use for KMP project? Java has
PriorityQueue
but I can’t use that for KMP. This message suggests
ArrayQueue
but it doesn’t have a Comparator that I can override
j
If you just want something that works today, use a normal list and do a binary search to find insertion index for new items
l
got it. tnx
e
or write a binary heap, it's not that much code
a
I’ve got some MinHeap priority queue lying around that came from this thread: https://codereview.stackexchange.com/questions/175291/minimum-priority-queue-implementation-in-kotlin
l
Thank you so much @ephemient!
a
Just in case, this is PriorityQueue that I've been using so far.
l
Thank you!
e
also, if you have any interest in writing a Fibonacci heap instead of a binary heap,

https://youtu.be/6JxvKfSV9Ns

is a good introduction (but a binary heap is almost always good enough)
449 Views