On Sunday, 9 August 2015 at 15:41:33 UTC, Alex Parrill wrote:

Why not just use std.random.shuffle [1]?


Well, I didn't knew about it, that's the reason ...

For the shuffle method, it is certainly the best to do, but I need the remove() method at other places. I see that remove() removes the value of the element but keeps the same size of the array, and replace the value by a new one at the end. The method :

class sabot{
        card[] sabotarray ;

        (...)

        card getCard(){
                card returncard = this.sabotarray[0] ;
                this.sabotarray.remove(0) ;
                return returncard ;
        }

The sabotarray before taking away cards :

$ dmd -run sabot.d
0. 🂡
1. 🂢
2. 🂣
...
48. 🃚
49. 🃛
50. 🃝
51. 🃞

The sabotarray after removing the two first cards :

$ dmd -run sabot.d
0. 🂣
1. 🂤
2. 🂥
...
47. 🃛
48. 🃝
49. 🃞
50. 🃞
51. 🃞



Reply via email to