PQ.NET 1.0.0

dotnet add package PQ.NET --version 1.0.0                
NuGet\Install-Package PQ.NET -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<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                
#r "nuget: PQ.NET, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. 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                

PQ.NET

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

Installing

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

Prerequisites

No prerequisites.

Usage

instantiation:

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

enqueuing:

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

dequeuing:

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

peeking:

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

adding new priority level:

pq.AddPriorityLevel(newPriorityLevel);

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:

pq.DeleteAllElementsFromQueueWithPriorityLevel(priorityLevel);

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>;
            };

properties:

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 Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 was computed.  netstandard2.1 was computed. 
.NET Framework net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
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 1,288 1/24/2018