.Net 中的优先队列 [英] Priority queue in .Net

查看:29
本文介绍了.Net 中的优先队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找优先队列或堆数据结构的 .NET 实现

I am looking for a .NET implementation of a priority queue or heap data structure

优先队列是比简单排序提供更多灵活性的数据结构,因为它们允许新元素以任意间隔进入系统.将新作业插入优先级队列比在每次到达时重新排序所有作业的成本效益要高得多.

Priority queues are data structures that provide more flexibility than simple sorting, because they allow new elements to enter a system at arbitrary intervals. It is much more cost-effective to insert a new job into a priority queue than to re-sort everything on each such arrival.

基本优先级队列支持三种主要操作:

The basic priority queue supports three primary operations:

  • 插入(Q,x).给定键为 k 的项 x,将其插入优先级队列 Q.
  • 求最小值(Q).返回指向该项目的指针其键值小于优先级队列中的任何其他键问:
  • 删除-最小值(Q).从优先级队列 Q 中移除 key 最小的项

除非我找错了地方,否则框架中没有.有没有人知道一个好的,还是我应该自己动手?

Unless I am looking in the wrong place, there isn't one in the framework. Is anyone aware of a good one, or should I roll my own?

推荐答案

我喜欢在 PowerCollections 作为优先队列.

I like using the OrderedBag and OrderedSet classes in PowerCollections as priority queues.

这篇关于.Net 中的优先队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆