Priority Queues in .NET

published on 2022/12/25

A PriorityQueue is a collection of items that have a value and a priority; as you can imagine, they act as a queue: the main operations are "add an item to the queue", called Enqueue, and "remove an item from the queue", named Dequeue. The main difference from a simple Queue is that on dequeue, the item with lowest priority is removed.

In this article, we're gonna use a PriorityQueue and wrap it into a custom class to solve one of its design issues (that I hope they'll be addressed in a future release of dotNET).