A high-performance, thread-safe priority queue for .NET 10 that guarantees uniqueness of items. Ideal for scheduling, task management, and scenarios where duplicate entries must be avoided.
$ dotnet add package CounterpointCollective.UniquePriorityQueueA high-performance priority queue for .NET 10 that guarantees key uniqueness.
Enqueue calls update the existing entry.Add the NuGet package to your project:
dotnet add package CounterpointCollective.UniquePriorityQueue
var queue = new UniquePriorityQueue<string, string, int>();
// Add items (lower priority numbers dequeue first)
queue.Enqueue("a", "First task", 5);
queue.Enqueue("b", "Urgent task", 1);
// Update an existing key
queue.Enqueue("a", "Updated task", 0);
// Peek lowest-priority item
var (key, value, p) = queue.Peek();
// key = "a", p = 0
// Dequeue in ascending priority order
while (queue.TryDequeue(out key, out value, out p))
{
Console.WriteLine($"{key}: {value} (priority {p})");
}
UniquePriorityQueue<TKey, TValue, TPriority>: Main queue type.UniquePriorityQueue.cs: Core implementation.MIT
Maintained by CounterpointCollective.