稳定的优先级队列 [英] Stable priority queue

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

问题描述

你好,


我明白一个简单的方法来使标准std :: priority_queue

稳定是通过在每个节点中包含一个整数标记每次将新节点推入队列时,
都会递增。但是,没有

重要的是我用于印章的合理大小的类型,最终

印章将'环绕''并且可能导致错误的订购

元素。对于我的应用程序,它非常快速地排队元素并且无限期地运行
,这个场景是一个真正的问题,

并且最终将导致不正确的结果。 />

有没有简单而无痛的方法来纠正这个订单邮票

环绕式问题?

Aaron W. LaFramboise

Hello,

I understand that an easy way to make the standard std::priority_queue
stable is by including an integer stamp with each node that is
incremented each time a new node is pushed into the queue. However, no
matter what reasonably-sized type I use for the stamp, eventually the
stamp will ''wrap around'' and possibly cause incorrect ordering of
elements. For my application, which queues elements very quickly and
runs for an indefinite amount of time, this scenario is a real concern,
and will eventually cause incorrect results.

Is there any easy and painless way of correcting this order-stamp
wraparound problem?
Aaron W. LaFramboise

推荐答案



" Aaron W. LaFramboise" < AA ******** @ cox-internet.com>在消息中写道

news:10 ************* @ corp.supernews.com ...

"Aaron W. LaFramboise" <aa********@cox-internet.com> wrote in message
news:10*************@corp.supernews.com...
你好,

我理解,使标准std :: priority_queue稳定的一种简单方法是在每次将新节点推入队列时为每个节点添加一个整数标记。但是,没有关于我用于印章的合理大小的类型,最终
印章将'环绕''并且可能导致
元素的错误排序。对于我的应用程序,它非常快速地排队元素并且无限期地运行,这种情况是一个真正的问题,
并最终会导致不正确的结果。

有没有任何简单而无痛的方法来纠正这个订单邮票的回收问题?

Aaron W. LaFramboise
Hello,

I understand that an easy way to make the standard std::priority_queue
stable is by including an integer stamp with each node that is
incremented each time a new node is pushed into the queue. However, no
matter what reasonably-sized type I use for the stamp, eventually the
stamp will ''wrap around'' and possibly cause incorrect ordering of
elements. For my application, which queues elements very quickly and
runs for an indefinite amount of time, this scenario is a real concern,
and will eventually cause incorrect results.

Is there any easy and painless way of correcting this order-stamp
wraparound problem?
Aaron W. LaFramboise




我不喜欢知道这对你有帮助,但是...


在我帮助写的服务器应用程序中,我们得到了当地的日期/时间信息和

创建了一个标识队列排序的字符串。我们

将字符串设置为以下格式:


YYYYMMDDHHNNSSTTT


其中


YYYY =年

MM =月

DD =天

HH =小时

NN =分钟

SS =秒

TTT =毫秒


(如果你的排队速度超过了允许的速度,那么你可以添加一个

整数计数,这可以自由包装,因为你没有
可能超过这个限制!:-))


现在已经好了三年了。好吧,系统已经重启了

那个时候(毕竟是Windows,所以:-)),但队列是在启动时恢复的b / b
所以订购仍然保存得当。


-Howard




I don''t know if this will help you but...

In a server application I helped write, we got the local date/time info and
created a string from that which identified the ordering of the queue. We
set the string to be the following format:

YYYYMMDDHHNNSSTTT

where

YYYY=year
MM=month
DD=day
HH=hours
NN=minutes
SS=seconds
TTT=milliseconds

(If you are queuing faster than that will allow for, then you can add an
integer count to the end of that, which can be free to wrap since you''re not
likely to exceed THAT limit! :-))

That''s worked fine for three years now. Wel, the system''s been rebooted
several times in that time (it is Windows, after all :-)), but the queue is
restored on startup, so the ordering is still preserved properly.

-Howard





Aaron W. LaFramboise < AA ******** @ cox-internet.com>在消息中写道

news:10 ************* @ corp.supernews.com ...

"Aaron W. LaFramboise" <aa********@cox-internet.com> wrote in message
news:10*************@corp.supernews.com...
你好,

我理解,使标准std :: priority_queue稳定的一种简单方法是在每次将新节点推入队列时为每个节点添加一个整数标记。但是,没有关于我用于印章的合理大小的类型,最终
印章将'环绕''并且可能导致
元素的错误排序。对于我的应用程序,它非常快速地排队元素并且无限期地运行,这种情况是一个真正的问题,
并最终会导致不正确的结果。

有没有任何简单而无痛的方法来纠正这个订单邮票的回收问题?

Aaron W. LaFramboise
Hello,

I understand that an easy way to make the standard std::priority_queue
stable is by including an integer stamp with each node that is
incremented each time a new node is pushed into the queue. However, no
matter what reasonably-sized type I use for the stamp, eventually the
stamp will ''wrap around'' and possibly cause incorrect ordering of
elements. For my application, which queues elements very quickly and
runs for an indefinite amount of time, this scenario is a real concern,
and will eventually cause incorrect results.

Is there any easy and painless way of correcting this order-stamp
wraparound problem?
Aaron W. LaFramboise




我不喜欢知道这对你有帮助,但是...


在我帮助写的服务器应用程序中,我们得到了当地的日期/时间信息和

创建了一个标识队列排序的字符串。我们

将字符串设置为以下格式:


YYYYMMDDHHNNSSTTT


其中


YYYY =年

MM =月

DD =天

HH =小时

NN =分钟

SS =秒

TTT =毫秒


(如果你的排队速度超过了允许的速度,那么你可以添加一个

整数计数,这可以自由包装,因为你没有
可能超过这个限制!:-))


现在已经好了三年了。好吧,系统已经重启了

那个时候(毕竟是Windows,所以:-)),但队列是在启动时恢复的b / b
所以订单仍然保存得当。


-Howard




I don''t know if this will help you but...

In a server application I helped write, we got the local date/time info and
created a string from that which identified the ordering of the queue. We
set the string to be the following format:

YYYYMMDDHHNNSSTTT

where

YYYY=year
MM=month
DD=day
HH=hours
NN=minutes
SS=seconds
TTT=milliseconds

(If you are queuing faster than that will allow for, then you can add an
integer count to the end of that, which can be free to wrap since you''re not
likely to exceed THAT limit! :-))

That''s worked fine for three years now. Wel, the system''s been rebooted
several times in that time (it is Windows, after all :-)), but the queue is
restored on startup, so the ordering is still preserved properly.

-Howard



" Aaron W. LaFramboise" < AA ******** @ cox-internet.com>在消息中写道
"Aaron W. LaFramboise" <aa********@cox-internet.com> wrote in message
我理解使标准std :: priority_queue稳定的一种简单方法是通过在每个节点上加一个整数标记来增加每次将新节点推入队列时。但是,没有关于我用于印章的合理大小的类型,最终
印章将'环绕''并且可能导致
元素的错误排序。对于我的应用程序,它非常快速地排队元素并且无限期地运行,这种情况是一个真正的问题,
并最终会导致不正确的结果。

有没有任何简单而无痛的方法来纠正这个订单邮票的回收问题?
I understand that an easy way to make the standard std::priority_queue
stable is by including an integer stamp with each node that is
incremented each time a new node is pushed into the queue. However, no
matter what reasonably-sized type I use for the stamp, eventually the
stamp will ''wrap around'' and possibly cause incorrect ordering of
elements. For my application, which queues elements very quickly and
runs for an indefinite amount of time, this scenario is a real concern,
and will eventually cause incorrect results.

Is there any easy and painless way of correcting this order-stamp
wraparound problem?




什么是稳定的优先级队列?



What is a stable priority queue?


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

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