Priority Queues with C#



A priority queue is held information with a priority value. It is an extension of queue.

The item with the highest property is removed first when you try to eliminate an item from a priority queue.

Let us see how to set priority queue −

public class MyPriorityQueue <T> where T : IComparable <T> {

}

Now let us add an item. In the below example the items get stored in info, which is a generic list.

Example

public class MyPriorityQueue <T> where T : IComparable <T> {
   private List <T> info;

   public MyPriorityQueue() {
      this.info = new List <T>();
   }
}
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know


Advertisements