小编sta*_*ean的帖子

在Java优先级队列实现中删除方法,为什么它会在筛选后进行筛选?

我一直在阅读Java集合API,这是优先级队列部分,由两位大师的作品Josh Bloch和Doug Lea实现.

Java PriorityQueue是用数组堆实现的.

代码片段来自PriorityQueue.java第600行:

/**
 * Removes the ith element from queue.
 *
 * Normally this method leaves the elements at up to i-1,
 * inclusive, untouched.  Under these circumstances, it returns
 * null.  Occasionally, in order to maintain the heap invariant,
 * it must swap a later element of the list with one earlier than
 * i.  Under these circumstances, this method returns the element
 * that was previously at the end of the …
Run Code Online (Sandbox Code Playgroud)

java heap priority-queue

5
推荐指数
1
解决办法
507
查看次数

标签 统计

heap ×1

java ×1

priority-queue ×1