title: delete queue items inside foreach loop
body: <p>When we need to delete some items inside a queue, we may easily write code like below:</p>
  
  <pre><code>foreach(queue[i]) begin
      if(queue[i].value == 1)
           queue.delete(i);
  end
  </code></pre>
  
  <p>But there is bugs in above code when queue[0]==queue[1]==1. Because queue.delete(0) will change all indexes of items inside queue.</p>
  
  <p>So currently I use code as below:</p>
  
  <pre><code>foreach(queue[i]) begin
      if(queue[i].value == 1) begin
           queue.delete(i);
           i--;
      end
  end
  </code></pre>
  
  <p>It works, but it looks confusing at first glance. </p>
  
  <p>So my question is: 
  Are there any better solution for this issue in system verilog?</p>