Friday, 6 September 2013

How to iterate PriorityBlockingQueue in order

How to iterate PriorityBlockingQueue in order

I have a PriorityBlockingQueue<Shirts> that uses a FIFO (first in first
out) comparator in addition to other custom conditions. While obeying the
priority, I need to pull out only the Green shirts. I understand the
objective with a Queue is that they are intended for items to be "taken
off of the top". The iterator() doesn't obey the order, so I can't use
that. Should I be using a different queue altogether? How can I iterate
over these items.

No comments:

Post a Comment