Comparison

util/indexedbheap.lua @ 11115:7d4c292f178e 0.11

util.indexedbheap: Fix heap datastructure corruption in :reschedule(smaller_value)
author Waqas Hussain <waqas20@gmail.com>
date Tue, 29 Sep 2020 21:27:16 -0500
parent 8382:e5d00bf4a4d5
comparison
equal deleted inserted replaced
11073:5691b9773c5b 11115:7d4c292f178e
21 local function _percolate_up(self, k, sync, index) 21 local function _percolate_up(self, k, sync, index)
22 local tmp = self[k]; 22 local tmp = self[k];
23 local tmp_sync = sync[k]; 23 local tmp_sync = sync[k];
24 while k ~= 1 do 24 while k ~= 1 do
25 local parent = math_floor(k/2); 25 local parent = math_floor(k/2);
26 if tmp < self[parent] then break; end 26 if tmp >= self[parent] then break; end
27 self[k] = self[parent]; 27 self[k] = self[parent];
28 sync[k] = sync[parent]; 28 sync[k] = sync[parent];
29 index[sync[k]] = k; 29 index[sync[k]] = k;
30 k = parent; 30 k = parent;
31 end 31 end