Encapsulate obscure detail that lower numeric priority is higher queue priority
authorclinton <clinton@unknownlamer.org>
Thu, 13 Nov 2008 06:45:51 +0000 (06:45 +0000)
committerclinton <clinton@unknownlamer.org>
Thu, 13 Nov 2008 06:45:51 +0000 (06:45 +0000)
source/ServerQueue.C
source/ServerQueueItem.C
source/ServerQueueItem.H

index d0432f7..0f13d36 100644 (file)
@@ -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;
        }
index e67bae2..8daf8c4 100644 (file)
@@ -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,
index c57838e..2e163b8 100644 (file)
@@ -35,6 +35,8 @@ public:
   virtual bool merge(ServerQueueItem *) { return false; }
   virtual String getLine() = 0;
 
+  bool operator< (const ServerQueueItem & item);
+
   friend class ServerQueue;
 
 private: