Closed sm2017 closed 7 years ago
Can you elaborate?
Some pointers:
I have object={ priority:integer , durable:boolean}
, I add object to queue and poll it when I need
Sometimes , I must get and remove all objects with durable=false
from queue , How can I do this?
Create two priority queues, one for durable elements and one for those that aren't durable. Instead of polling just one queue, peek two queues, polling the best one. When you add elements, make sure they get added to the right queue.
@lemire but it is not solution because each time I just peek one item from queue and if I have two queue it is not clear that with queue has priority
If you can write better approach, please issue a pull request.
How can I iterate over queue? I have a scenario when I lost connection I must iterate over queue and remove some items (Not all)