Remove instance from array
Andrea Fontana via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jul 6 01:15:10 PDT 2017
On Wednesday, 5 July 2017 at 16:17:29 UTC, Jolly James wrote:
> On Wednesday, 5 July 2017 at 16:04:16 UTC, Jolly James wrote:
>> On Wednesday, 5 July 2017 at 15:56:45 UTC, Igor Shirkalin
>> wrote:
>>> [...]
>>
>> Thank you! :)
>>
>>
>> But why a containers so complicated in D?
>>
>> [...]
>
>
>
> Part of CoreCLR's 'List<T>':
>
>> public bool Remove(T item)
>> {
>> int index = IndexOf(item);
>> if (index >= 0)
>> {
>> RemoveAt(index);
>> return true;
>> }
>>
>> return false;
>> }
>> //
>> https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Collections/Generic/List.cs
>
>
> If there isn't already, maybe something similar to this should
> get part of Phobos. I think this could be really useful.
q = q.remove(1); // Remove element with index 1
q = q.remove(x => x == instance); // Remove all items that match
instance
More information about the Digitalmars-d-learn
mailing list