How to delete duplicate elements from associative array and Queue in System Verilog

In reply to ritheshraj:

For a queue, you can refer the following code:


    int index[$];
    do begin
      index = q_int.find_index(x) with (x == 500);
      if(index.size()) begin
        q_int.delete(index.pop_front());
      end
    end
    while(index.size());

Or this way:


    for(int i = 0; i < q_int.size(); i++) begin
      if(q_int[i] == 500) begin
        q_int.delete(i--);
      end
    end