Search code examples
c#.netcollectionsf#priority-queue

Microsoft Collections for .NET


.NET comes with some built in collections (stack, queue, dictionary, list etc.) but others common collections, like priority queues, are missing. There are many third party collection libraries on NuGet but I was wondering if there is an official Microsoft one (like the BCL immutable collections now called System.Collections.Immutable) library with things like (mutable) priorities queues?

EDIT: Important clarification (comment by @rmunn):

This question is not asking to recommend a library for X, it is asking a factual question, "Are there any official Microsoft libraries for X?"


Solution

  • .NET 6+: .NET 6 adds a System.Collections.Generic.PriorityQueue<TElement,TPriority> class. And FWIW it is open-source and implemented in c#.

    Earlier .NET Core versions and .NET Framework: Microsoft has written (and shared online) 2 internal PriorityQueue classes within the .NET Framework. You could use their code.

    See also: Priority queue in .Net