PriorityQueue.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:hip-mdp-public 作者: dtak 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号