From: clinton Date: Thu, 13 Nov 2008 06:45:51 +0000 (+0000) Subject: Encapsulate obscure detail that lower numeric priority is higher queue priority X-Git-Tag: release-2.3.1~50 X-Git-Url: https://git.hcoop.net/clinton/bobotpp.git/commitdiff_plain/94a034218b31a931763efc2b1fca6699af471653 Encapsulate obscure detail that lower numeric priority is higher queue priority --- diff --git a/source/ServerQueue.C b/source/ServerQueue.C index d0432f7..0f13d36 100644 --- a/source/ServerQueue.C +++ b/source/ServerQueue.C @@ -46,7 +46,7 @@ ServerQueue::addItem(ServerQueueItem *sqi) for (it = serverQueue.begin(); it != serverQueue.end(); ++it) { - if ((*it)->priority > sqi->priority) + if (**it < *sqi) { break; } diff --git a/source/ServerQueueItem.C b/source/ServerQueueItem.C index e67bae2..8daf8c4 100644 --- a/source/ServerQueueItem.C +++ b/source/ServerQueueItem.C @@ -25,21 +25,23 @@ ServerQueueItem::ServerQueueItem(int pr, int pen, int t) : priority(pr), penalty(pen), type(t) { } - - ServerQueueOtherItem::ServerQueueOtherItem(String l, int pr, int pen, int t) : ServerQueueItem(pr, pen, t), line(l) { } +bool ServerQueueItem::operator< (const ServerQueueItem & item) +{ + // lower numeric priority is higher priority + return item.priority < priority; +} + String ServerQueueOtherItem::getLine() { return line; } - - ServerQueueChannelModeItem::ServerQueueChannelModeItem(String c, String m, String p) : ServerQueueItem(CHANNELMODE_PRIORITY, CHANNELMODE_PENALTY, diff --git a/source/ServerQueueItem.H b/source/ServerQueueItem.H index c57838e..2e163b8 100644 --- a/source/ServerQueueItem.H +++ b/source/ServerQueueItem.H @@ -35,6 +35,8 @@ public: virtual bool merge(ServerQueueItem *) { return false; } virtual String getLine() = 0; + bool operator< (const ServerQueueItem & item); + friend class ServerQueue; private: