![]() |
Question about PriorityQueue
I think so, that found a bug in the code: PriorityQueue class not correctly sorts the nodes by their priorities:
Code:
PriorityQueue testPriorityQueue; [17:05:10] Log: testPriorityQueue[0] == [7, 1.00]. [17:05:10] Log: testPriorityQueue[1] == [4, 10.00]. [17:05:10] Log: testPriorityQueue[2] == [5, 9.00]. [17:05:10] Log: testPriorityQueue[3] == [2, 100.00]. [17:05:10] Log: testPriorityQueue[4] == [1, 100.00]. [17:05:10] Log: testPriorityQueue[5] == [3, 100.00]. [17:05:10] Log: testPriorityQueue[6] == [6, 11.00]. Although to be so: [17:05:10] Log: testPriorityQueue[0] == [7, 1.00]. [17:05:10] Log: testPriorityQueue[1] == [5, 9.00]. [17:05:10] Log: testPriorityQueue[2] == [4, 10.00]. [17:05:10] Log: testPriorityQueue[3] == [6, 11.00]. [17:05:10] Log: testPriorityQueue[4] == [1, 100.00]. [17:05:10] Log: testPriorityQueue[5] == [2, 100.00]. [17:05:10] Log: testPriorityQueue[6] == [3, 100.00]. I think that the functions Code:
void PriorityQueue::Insert (int value, float priority) Code:
int PriorityQueue::Remove (void) Code:
void PriorityQueue::Insert (int value, float priority) P.S. In HL2 SDK in the class CUtlPriorityQueue same "problem" - this idea of developers? P.S.S. If I am wrong - please tell me. |
Re: Question about PriorityQueue
IIRC I ripped that code from HL1 SDK, so thaty may be why it's similar as HL2 SDK.
Basically that code only ensures the data is stored as a heap, i.e. the one to be popped is the smallest. And doesn't sort everything. |
Re: Question about PriorityQueue
Quote:
Hmm, strange, but what I have suggested that faster and more accurately for YaPB pathfinding, why not use it? |
Re: Question about PriorityQueue
well as long as the pathfinder only uses the CQueuePriority::Remove() function rather than accessing the m_heap array directly (which is private btw) it isn't inaccurate at all.
And heaps usually cost less comparation and moving operations (i.e. faster) than insertion sort. |
All times are GMT +2. The time now is 00:59. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.