PriorityQueue
implements Queue
, but is PriorityQueue
a FIFO data structure like Queue
?
Advertisement
Answer
From the Queue interface:
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
So PriorityQueue is an exception and it becomes a FIFO queue only if the comparator sorts in that order.