I am looking for a .NET implementation of a priority queue or heap data structure
Priority queues are data structures that provide more flexibility than simple sorting, because they allow new elements to enter a system at arbitrary intervals. It is much more cost-effective to insert a new job into a priority queue than to re-sort everything on each such arrival.
The basic priority queue supports three primary operations:
- Insert(Q,x). Given an item x with key k, insert it into the priority queue Q.
- Find-Minimum(Q). Return a pointer to the item whose key value is smaller than any other key in the priority queue Q.
- Delete-Minimum(Q). Remove the item from the priority queue Q whose key is minimum
Unless I am looking in the wrong place, there isn't one in the framework. Is anyone aware of a good one, or should I roll my own?
I like using the OrderedBag
and OrderedSet
classes in PowerCollections as priority queues.