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

查看:190
本文介绍了.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)。从最小的优先队列Q中删除该项目

除非我看错了地方,框架中没有一个。有没有人知道一个好的,或者我应该自己滚动?

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?

推荐答案

我喜欢使用OrderedBag和OrderedSet类在<一个href =http://www.codeplex.com/PowerCollections =noreferrer> PowerCollections 作为优先队列。

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

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

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