title: How to match and delete an element from a queue?
body: <p>According to <a href="http://standards.ieee.org/getieee/1800/download/1800-2012.pdf" rel="nofollow">1800-2012 specs</a>, </p>
  
  <pre><code>Queue::delete( [input int index] ) 
  </code></pre>
  
  <p>deletes an element of a queue in SystemVerilog, furthermore, a Queue can perform the same operations as an unpacked Array, giving it access to:</p>
  
  <pre><code>Array::find_first_index( )
  </code></pre>
  
  <p>which returns the index of the first element matching a certain criteria. i.e.</p>
  
  <pre><code>find_first_index( x ) with ( x == 3)
  </code></pre>
  
  <p>Now I'd like to delete a unique item, guaranteed to exist, from the Queue. Combining 1 and 1 gives me:</p>
  
  <pre><code>queue.delete(queue.find_first_index( x ) with ( x == obj_to_del ));
  </code></pre>
  
  <p>The compiler does not appreciate that though saying that the argument passed must be either an integer or integer compatible. I could probably pull the two apart:</p>
  
  <pre><code>int index = queue.find_first_index( x ) with ( x == obj_to_del );
  queue.delete( index );
  </code></pre>
  
  <p>or force an integer by typecasting find_first_index:</p>
  
  <pre><code>queue.delete(int'(queue.find_first_index( x ) with ( x == obj_to_del ))) //Just finished compiling, does not work.
  </code></pre>
  
  <p>The former does not look very elegant to me, and the latter seems somewhat forced which made me curious if there is maybe a more proper way to accomplish this. Is find_first_index possibly returning an array of size one with the index at location 0?</p>
  
  <p>EDIT: I foolishly did not provide a self contained example: A stripped example of what I'm doing looks like:</p>
  
  <pre><code>class parent_task;
  endclass;
  
  class child_taskA extends parent_task;
  endclass;
  
  class child_taskB extends parent_task;
  endclass;    
  
  class task_collector;
  
   child_taskA A_queue[$];
   child_taskB B_queue[$];
  
   function delete_from_queue(parent_task task_to_del);
        case (task_to_del.type):
           A: A_queue.delete(A_queue.find_first_index( x ) with ( x == task_to_del));
           B: B_queue.delete(B_queue.find_first_index( x ) with ( x == task_to_del));
           default: $display("This shouldn't happen.");
   endfunction
  endclass
  </code></pre>
  
  <p>The error message, word for word is:</p>
  
  <pre><code>Error-[SV-IQDA] Invalid Queue delete argument
  "this.A_queue.find_first_index( iterator ) with ((iterator == task))"
   Queue method delete can take optional integer argument. So, argument passed
   to it must be either integer or integer assignment compatible.
  </code></pre>
  
  <p>There are checks in place to make sure that the task in question exists before the call to delete_from_queue.</p>