What is the replacement for deprecated array removal

kerdemdemir kerdemdemir at gmail.com
Mon Nov 18 21:25:12 UTC 2019


On Monday, 18 November 2019 at 21:14:53 UTC, Steven Schveighoffer 
wrote:
> On 11/18/19 3:53 PM, kerdemdemir wrote:
>
>> Is there any way to remove list of elements efficiently with a 
>> dynamical array?
>
> It seems kind of silly that it's not allowed, but maybe it will 
> be possible after the deprecation is removed.
>
> But you could do something like this:
>
> list = list.remove!(a => removeList.canFind(a));
>
> This is going to suck. Because it's O(n^2). Should be O(n + m) 
> way to do it (assuming you have a sorted index list).
>
>> 
>> Or is there anyway converting a dynamical array into a form 
>> which is like a AliasSeq?
>
> An AliasSeq is a compile-time construct, and cannot be created 
> from a runtime array.
>
> -Steve

Thanks for awesome answers man ,

Yes that sucks real hard because unlike that dummy example in my 
real case == compression will be too expensive I can't simply use 
canFind on every index.

I guess I need to recreate a new dynamical array each time which 
is also horrible.

It is a bit weird that such a general case like removing list of 
elements does not work.

And I really do not know the real use of [0,1,2,3].remove(1,2,3). 
I mean in unit test it looks cool but in real life you will have 
dynamically calculated indexes.

Erdem








More information about the Digitalmars-d-learn mailing list