def pop(self):
"""
Removes and returns [priority, exp_idx] for the
the maxmimum priority element
"""
if self.size == 0:
return None
# Get max element (first element in pq_array)
max_elt = np.copy(self.pq_array[0])
# Most the last value (not necessarily the smallest) to the root
self.pq_array[0] = self.pq_array[self.size-1]
self.size -= 1
# Update hash tables
self.exp_hash[self.pq_array[0,1]], self.pq_hash[0] = 0, self.pq_array[0,1]
# Rebalance
self.__down_heap(0)
return max_elt
评论列表
文章目录