Delete an element from queue by name

In reply to sv_uvm_learner_1:

All of the find_* methods return a queue type. This is so it can return an empty queue if there is no match. So you will need to do

string queue_2[$];
int blue_index[$];

initial begin
   queue_2 = {"Red","Blue","Green"};
   blue_index = queue_2.find_first_index with (item == "BLUE");
   foreach(blue_index[del]) queue_2.delete(del);
end
1 Like