shanghai1943 Posted March 11, 2021 Report Share Posted March 11, 2021 Hi dears, Are there any simple ways to randomize a queue (say q1[$]) or an dynamic array (say a1[]) with different value of each element ? thanks! Quote Link to comment Share on other sites More sharing options...
chr_sue Posted March 11, 2021 Report Share Posted March 11, 2021 A queue or a dynamic array do not have any content when declared, i.e. there is nothing to randomize. When you have entries in your queue/array you can simply call shuffle. This will randomize the order of the elements in the arrays. Quote Link to comment Share on other sites More sharing options...
shanghai1943 Posted March 11, 2021 Author Report Share Posted March 11, 2021 1 hour ago, chr_sue said: A queue or a dynamic array do not have any content when declared, i.e. there is nothing to randomize. When you have entries in your queue/array you can simply call shuffle. This will randomize the order of the elements in the arrays. You may not get me. I mean after I specify the size of queue/array, how to randomize the q/array with different values of each element? Quote Link to comment Share on other sites More sharing options...
shanghai1943 Posted March 11, 2021 Author Report Share Posted March 11, 2021 fine, maybe I've gotten the probable solution with unique constraint. But welcome you to give other solutions, thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.