core/sm_simple_prioqueue.h
author Scott Ehlert <ds@alliedmods.net>
Sun Jul 15 08:00:26 2007 +0000 (2007-07-15)
changeset 1116 40cc5e9f0f1b
parent 1098 6d5921e1f931
child 1157 61c7092246c6
permissions -rw-r--r--
Removed strange debugging code
     1 /**
     2  * vim: set ts=4 :
     3  * ===============================================================
     4  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     5  * ===============================================================
     6  *
     7  * This file is not open source and may not be copied without explicit
     8  * written permission of AlliedModders LLC.  This file may not be redistributed 
     9  * in whole or significant part.
    10  * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
    11  *
    12  * Version: $Id$
    13  */
    14 
    15 #include "sm_queue.h"
    16 
    17 enum PrioQueueLevel
    18 {
    19 	PrioQueue_High,
    20 	PrioQueue_Normal,
    21 	PrioQueue_Low
    22 };
    23 
    24 template <class T>
    25 class PrioQueue
    26 {
    27 private:
    28 	Queue<T> m_HighQueue;
    29 	Queue<T> m_NormalQueue;
    30 	Queue<T> m_LowQueue;
    31 public:
    32 	inline Queue<T> & GetQueue(PrioQueueLevel level)
    33 	{
    34 		if (level == PrioQueue_High)
    35 		{
    36 			return m_HighQueue;
    37 		} else if (level == PrioQueue_Normal) {
    38 			return m_NormalQueue;
    39 		} else {
    40 			return m_LowQueue;
    41 		}
    42 	}
    43 	inline Queue<T> & GetLikelyQueue()
    44 	{
    45 		if (!m_HighQueue.empty())
    46 		{
    47 			return m_HighQueue;
    48 		}
    49 		if (!m_NormalQueue.empty())
    50 		{
    51 			return m_NormalQueue;
    52 		}
    53 		return m_LowQueue;
    54 	}
    55 };