RAndomize a Queue in System Verilog

In reply to donald:

You have to check the size of the queue just before randomizing the queue as below,



seq obj = new;
if(obj.my_q.size() != 0)
begin
     if(obj.randomize() == 1)   
     $display("Randomizing is done");
     //Do Something with the Queue here
     else
     $display("Randomization failed");
end
else
$display("\n Didn't Randomize as my_q.size() is not equal to zero \n");]

Thanks,
Sravan K