Comparison

util/indexedbheap.lua @ 8382:e5d00bf4a4d5

util: Various minor changes to please [luacheck]
author Kim Alvefur <zash@zash.se>
date Fri, 10 Nov 2017 05:42:32 +0100
parent 6151:a34a14054532
child 11115:7d4c292f178e
comparison
equal deleted inserted replaced
8381:7f6184474149 8382:e5d00bf4a4d5
108 local k = self.index[id]; 108 local k = self.index[id];
109 if k == nil then return; end 109 if k == nil then return; end
110 self.priorities[k] = priority; 110 self.priorities[k] = priority;
111 111
112 k = _percolate_up(self.priorities, k, self.ids, self.index); 112 k = _percolate_up(self.priorities, k, self.ids, self.index);
113 k = _percolate_down(self.priorities, k, self.ids, self.index); 113 _percolate_down(self.priorities, k, self.ids, self.index);
114 end 114 end
115 function indexed_heap:remove_index(k) 115 function indexed_heap:remove_index(k)
116 local result = self.priorities[k]; 116 local result = self.priorities[k];
117 if result == nil then return; end 117 if result == nil then return; end
118 118
130 self.index[result_sync] = nil; 130 self.index[result_sync] = nil;
131 self.items[result_sync] = nil; 131 self.items[result_sync] = nil;
132 132
133 if size > k then 133 if size > k then
134 k = _percolate_up(self.priorities, k, self.ids, self.index); 134 k = _percolate_up(self.priorities, k, self.ids, self.index);
135 k = _percolate_down(self.priorities, k, self.ids, self.index); 135 _percolate_down(self.priorities, k, self.ids, self.index);
136 end 136 end
137 137
138 return result, item, result_sync; 138 return result, item, result_sync;
139 end 139 end
140 function indexed_heap:remove(id) 140 function indexed_heap:remove(id)