41 #ifndef _KD_PRIORITY_QUEUE_H_
42 #define _KD_PRIORITY_QUEUE_H_
72 m_nMaxSize = nMaxSize;
76 m_pQueue =
new KdQueueEntry[nMaxSize + 1];
97 inline void Push(
float fValue,
void* pMeta)
100 if (++m_nSize > m_nMaxSize)
106 register int nPos = m_nSize;
109 register int nHalf = nPos / 2;
112 if (m_pQueue[nHalf].fValue <= fValue)
116 m_pQueue[nPos] = m_pQueue[nHalf];
121 m_pQueue[nPos].fValue = fValue;
122 m_pQueue[nPos].pMeta = pMeta;
125 inline void Pop(
float& fValue,
void*& pMeta)
128 fValue = m_pQueue[1].fValue;
129 pMeta = m_pQueue[1].pMeta;
131 register float fLast = m_pQueue[m_nSize--].fValue;
133 register int nPos = 1;
134 register int nDouble = nPos << 1;
137 while (nDouble <= m_nSize) {
140 if (nDouble < m_nSize && m_pQueue[nDouble].fValue > m_pQueue[nDouble + 1].fValue)
144 if (fLast <= m_pQueue[nDouble].fValue)
148 m_pQueue[nPos] = m_pQueue[nDouble];
155 m_pQueue[nPos] = m_pQueue[m_nSize + 1];
164 KdQueueEntry *m_pQueue;
void Pop(float &fValue, void *&pMeta)
CKdPriorityQueue(int nMaxSize)
void Push(float fValue, void *pMeta)