Library code snippets

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.

Comments

  1. 21 Jul 2007 at 06:06

    Hi i am an engg student..

    i need a resource sharing project codings in VB.NET

    plz anyone can send sample codings for me....

  2. 01 Jan 1999 at 00:00

    This thread is for discussions of Priority Queue .NET.

Leave a comment

Sign in or Join us (it's free).

Rasto Novotny

Related discussion

Related podcasts

  • xpert to Expert: Inside Concurrent Basic (CB)

    "Concurrent Basic extends Visual Basic with stylish asynchronous concurrency constructs derived from the join calculus. Our design advances earlier MSRC work on Polyphonic C#, Comega and the Joins Library. Unlike its C# based predecessors, CB adopts a simple event-like syntax familiar to VB progr...

We'd love to hear what you think! Submit ideas or give us feedback