PQ.NET 1.0.0

.NET Standard 1.3
Install-Package PQ.NET -Version 1.0.0
dotnet add package PQ.NET --version 1.0.0
<PackageReference Include="PQ.NET" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PQ.NET --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PQ.NET, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install PQ.NET as a Cake Addin
#addin nuget:?package=PQ.NET&version=1.0.0

// Install PQ.NET as a Cake Tool
#tool nuget:?package=PQ.NET&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.


Priority queue for net standard v1.3 and up, thread safe, no 3-rd party dependencies.


Package manager: Install-Package PQ.NET
.NET CLI: dotnet add package PQ.NET


No prerequisites.



var pq = new Pq<T>(new uint[], defaultObjectReturnedInCaseTheQueueIsEmpty);


pq.Enqueue(T obj); => will enqueue on the lowest level of priority
pq.Enqueue(T obj, uint newLevelOfPriority);


pq.Dequeue(); => will dequeue from the max level priority downwards
pq.Dequeue(uint priorityLevel);


var peekedElement = pq.Peek();
var peekedElement = pq.Peek(priorityLevel);

adding new priority level:


adding new priority levels:

pq.AddPriorityLevels(newPriorityLevels); where newPriorityLevels = uint[]

adding new priority level with enqueue method:

pq.Enqueue(_defaultElementForEnqueue, newPriorityLevel);

deleting all elements with priority level:


counting elements in queue

pq.GetLengthOfQueue() => full length including all priority levels
pq.GetLengthOfQueue(priorityLevel) only the priority level specified

Events, and events sourcing

registering for an enqueuing event:

pq.ElementEnqueued += (sender, objWrapper) =>
                dispatchedEvent = objWrapper as EventArgsContainer<T>;

registering for dequeuing event:

pq.ElementDequeued += (sender, objWrapper) =>
                dispatchedEvent = objWrapper as EventArgsContainer<T>;


pq.ExistingPriorities => IList<uint> of all currently existing levels of priority;

Event History

Each action for enqueue or dequeue will be registerd here in pq.EventsHistory as PqEvent

structure of PqEvent:

 public class PqEvent<T>
        public Actions Action { get; } => Enum with two elements Enqueue and Dequeue;
        public T Value { get; }
        public DateTimeOffset TimeItHappened { get; }
        public uint Priority { get; }

        public PqEvent(Actions action, T value, uint priority)
            Action = action;
            Value = value;
            TimeItHappened = DateTimeOffset.UtcNow;
            Priority = priority;

This adding is done in method: AddEventToHistory, method that can be overriden if history becomes to big

Event broadcasting

public class EventArgsContainer<T> : EventArgs
        public PqEvent<T> Obj { get; }

        public EventArgsContainer(PqEvent<T> obj)
            Obj = obj;

Just cast EventArgs e to EventArgsContainer<T> and you will have the element that triggered the event.

Each method has a good documentation in code also , use it wisely

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp1.0 netcoreapp1.1 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard1.3 netstandard1.4 netstandard1.5 netstandard1.6 netstandard2.0 netstandard2.1
.NET Framework net46 net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen30 tizen40 tizen60
Universal Windows Platform uap uap10.0
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 980 1/24/2018