Priority Queue .NET

Priority queue is collection like stack or queue. Objects are pushed into priority front in any order, and a priority is assigned to each object. They can be then popped from priority front ordered by priority. It is able to specify if objects with lower priority are popped first or objects with greater priority are popped first.

Source code is available to download using the link below. Priority queue is implemented using heap (rooted binary tree), where each item has greater priority as it's children. So item with maximal priority is in root of the tree. Push and Pop operations are in O(log(n)) time. Heap is implemented as doubly-linked list of heap levels. Heap level is array of items. Level n+1 has 2 times as much items as level n. Item at index i in level n has left child at index  2*i and right child at index 2*i+1 at level n+1.

Priority Queue .NET is written for .NET Framework 2.0. It is generic type, where type of objects in the priority queue and type of priority are type-parameters.

You might also like...

Comments

Rasto Novotny

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Linux is only free if your time has no value” - Jamie Zawinski