Fast and efficient implementation of a Priority Queue.
$ dotnet add package ReconArt.PriorityQueueReconArt.PriorityQueue is a .NET library that provides a fast and efficient implementation of a priority queue with constant time complexity for all operations. It supports only 6 priorities, making it suitable for scenarios where a limited number of priority levels are sufficient.
To install the ReconArt.PriorityQueue package, use the NuGet Package Manager or the Package Manager Console with the following command:
Install-Package ReconArt.PriorityQueue
You can create a priority queue and add elements with specified priorities:
var priorityQueue = new PriorityQueue<string>();
// Enqueue elements with priorities (0 to 5, where 0 is the highest priority)
priorityQueue.Enqueue("High Priority Task", 0);
priorityQueue.Enqueue("Medium Priority Task", 2);
priorityQueue.Enqueue("Low Priority Task", 5);
Dequeue elements from the priority queue, which removes and returns the element with the highest priority:
var task = priorityQueue.Dequeue();
// task will be "High Priority Task"
Peek at the next element without removing it:
var nextTask = priorityQueue.Peek();
Remove a specific element by its node and priority:
var node = priorityQueue.Enqueue("Specific Task", 3);
bool removed = priorityQueue.TryRemove(node, 3);
If you'd like to contribute to the project, please reach out to the ReconArt/priority-queue team.
If you encounter any issues or require assistance, please file an issue in the GitHub Issues section of the repository.
Copyright © ReconArt, Inc. 2008-2024. All rights reserved.
Developed by ReconArt, Inc..