Priority Queues with C#

CsharpProgrammingServer Side Programming

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>();
   }
}
raja
Published on 14-Aug-2018 10:35:16
Advertisements