How to match and delete an element from a object queue?

Hello,

I have a parametrized transaction class, which has one property id.


class trans#(parameter int A) extends uvm_sequence_item;
  int id;
  ...
endclass

In other class I have queue of objects of trans type.
I want to write a method which will search the queue element property id and if it matches local id it will delete matched element.



...
trans#(64)  temp_tran[$];

temp_tran.delete(temp_tran.find_first_index(x) with (x.id == local_id));
...

well, this is not working, I get error that this is illegal assignment.
How can I fix it?

In reply to EleneSajaia:

The find_first_index() locator method still returns a queue (with a single item in it), not a single index. So you can’t one-line the delete() as you’re trying to do. There might be some way to one-line it, but I’d just do a:

int matched_index[$ ];
matched_index = temp_tran.find_first_index(x) with (x.id == local_id);
// Maybe add code here for non-matching exception handling
temp_tran.delete( matched_index[ 0 ] );