PriorityQueue
实现了Queue
,但是PriorityQueue
是像Queue
一样的FIFO 数据结构吗?
最佳答案
来自Queue界面:
Queues typically, but do not necessarily, order elements in a FIFO (first-in-first-out) manner. Among the exceptions are priority queues, which order elements according to a supplied comparator, or the elements' natural ordering
因此 PriorityQueue 是一个异常(exception),只有当比较器按该顺序排序时,它才会成为 FIFO 队列。
关于java - PriorityQueue 是 FIFO 队列吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12692479/