How to safely delete entries from a queue

In reply to murali.gubba:

Your code finds only the first matching index. However, I would like to delete all the entries matching a particular id.