Re: Removing elements from dynamic array

2015-08-09 Thread Reflexive via Digitalmars-d-learn
On Sunday, 9 August 2015 at 20:38:05 UTC, drug wrote: 09.08.2015 23:22, Reflexive пишет: Try to use this.sabotarray = this.sabotarray.remove(id_card); remove() removes element(s) but doesn't change length of 'old' array. To get new length you should use 'new' array that returned from remove

Re: Removing elements from dynamic array

2015-08-09 Thread drug via Digitalmars-d-learn
09.08.2015 23:22, Reflexive пишет: Try to use this.sabotarray = this.sabotarray.remove(id_card); remove() removes element(s) but doesn't change length of 'old' array. To get new length you should use 'new' array that returned from remove(). In this case I get rid of two excessive kings in ca

Re: Removing elements from dynamic array

2015-08-09 Thread anonymous via Digitalmars-d-learn
On Sunday, 9 August 2015 at 20:23:00 UTC, Reflexive wrote: 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(){

Re: Removing elements from dynamic array

2015-08-09 Thread Reflexive via Digitalmars-d-learn
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

Re: Removing elements from dynamic array

2015-08-09 Thread Alex Parrill via Digitalmars-d-learn
On Sunday, 9 August 2015 at 15:30:32 UTC, Reflexive wrote: I wrote import std.algorithm.remove ;, and I dont have any longer any error. But, it dont want to remove the item. Here is the source, the problem is in the shuffle() method : ... Why not just use std.random.shuffle [1]? import

Re: Removing elements from dynamic array

2015-08-09 Thread Reflexive via Digitalmars-d-learn
I wrote import std.algorithm.remove ;, and I dont have any longer any error. But, it dont want to remove the item. Here is the source, the problem is in the shuffle() method : // sabot.d // version 0.0.1 import std.stdio ; import std.random ; import std.algorithm : remove ; void main(){

Re: Removing elements from dynamic array

2015-08-09 Thread kinke via Digitalmars-d-learn
On Sunday, 9 August 2015 at 14:24:38 UTC, Reflexive wrote: Error: module remove is in file 'std/algorithm/remove.d' which cannot be read remove() is a function in module std.algorithm: import std.algorithm: remove; remove(foo);

Re: Removing elements from dynamic array

2015-08-09 Thread Rikki Cattermole via Digitalmars-d-learn
On 10/08/2015 2:24 a.m., Reflexive wrote: On Sunday, 9 August 2015 at 13:40:51 UTC, cym13 wrote: On Sunday, 9 August 2015 at 13:22:02 UTC, Reflexive wrote: You can use std.algorithm.remove for that. If you need more advanced ways to remove elements, you may want to switch from a regular dynamic

Re: Removing elements from dynamic array

2015-08-09 Thread Reflexive via Digitalmars-d-learn
On Sunday, 9 August 2015 at 13:40:51 UTC, cym13 wrote: On Sunday, 9 August 2015 at 13:22:02 UTC, Reflexive wrote: You can use std.algorithm.remove for that. If you need more advanced ways to remove elements, you may want to switch from a regular dynamic array to a std.container.array. I get

Re: Removing elements from dynamic array

2015-08-09 Thread cym13 via Digitalmars-d-learn
On Sunday, 9 August 2015 at 13:22:02 UTC, Reflexive wrote: Hi I have seen that it is possible to remove an element from a associative array, but dont find any reference, including in D's specification, about any element removing in dynamic array. I can use loops for that, but isnt any way to