PriorityQueues on .NET 7 and C# 11

2022-12-19

Starting from .NET 6 and C# 10, we finally have built-in support for PriorityQueues 🥳 A PriorityQueue is a collection of items that have a value and a priority; as you can imagine, they act as a queue: the main operations are “add an item to the queue”, called Enqueue, and “remove an item from the queue”, named Dequeue. The main difference from a simple Queue is that on dequeue, the item with lowest priority is removed. In this article, we’re gonna use a PriorityQueue and wrap it into a custom class to solve one of its design issues (that I hope they’ll be addressed in a future release of dotNET). This is the essence of a Priority Queue: insert items, give them a priority, then remove them starting from the one with lower priority.

Link [ https://www.code4it.dev/blog/intro-priority-queue ]

Previous Article

PriorityQueues on .NET 7 and C# 11

2022-12-19

Starting from .NET 6 and C# 10, we finally have built-in support for PriorityQueues 🥳 A PriorityQueue is a collection of items that have a value and a priority; as you can imagine, they act as a queue: the main operations are “add an item to the queue”, called Enqueue, and “remove an item from the queue”, named Dequeue. The main difference from a simple Queue is that on dequeue, the item with lowest priority is removed. In this article, we’re gonna use a PriorityQueue and wrap it into a custom class to solve one of its design issues (that I hope they’ll be addressed in a future release of dotNET). This is the essence of a Priority Queue: insert items, give them a priority, then remove them starting from the one with lower priority.

Link [ https://www.code4it.dev/blog/intro-priority-queue ]

Copyright © 2024 All rights reserved

Rss

Atom