-
Notifications
You must be signed in to change notification settings - Fork 16
Priority Queues
ikopylov edited this page Dec 26, 2014
·
2 revisions
Library contains a simple implementation of queue with limited number of priorities. Under cover it is a bunch of queues - one for every priority level.
Sample code for 2 level priority queue:
var queue = new HighLowPriorityQueue<int>();
// Enqueue item with low priority
queue.Enqueue(2, ServiceClasses.Collections.HighLowPriority.Low);
// Enqueue item with high priority
queue.Enqueue(1, ServiceClasses.Collections.HighLowPriority.High);
// Dequeue element (val1 will be 1)
int val1 = queue.Dequeue();
// Dequeue element (val2 will be 2)
int val2 = queue.Dequeue();
// The same enqueue as previously
queue.Enqueue(2);
queue.EnqueueHigh(1);