Thread overview | |||||
---|---|---|---|---|---|
|
October 12, 2014 DList!int.remove(range.takeOne) - workarounds? | ||||
---|---|---|---|---|
| ||||
DList seems to have an issue with remove: void main() { import std.container, std.range, std.algorithm; auto list = DList!int([1, 2, 4, 6]); auto res = find(list[], 2); list.remove(res); //ok /* list.remove(res.takeOne); Error: function std.container.dlist.DList!int.DList.remove (Range r) is not callable using argument types (Result) list.remove(res.take(1)); Error: function std.container.dlist.DList!int.DList.remove (Range r) is not callable using argument types (Take!(Range)) */ } Are there any known workarounds besides linearRemove? |
October 12, 2014 Re: DList!int.remove(range.takeOne) - workarounds? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Algo | On Sunday, 12 October 2014 at 09:45:22 UTC, Algo wrote:
> DList seems to have an issue with remove:
>
> void main()
> {
> import std.container, std.range, std.algorithm;
> auto list = DList!int([1, 2, 4, 6]);
> auto res = find(list[], 2);
> list.remove(res); //ok
> /*
> list.remove(res.takeOne);
> Error: function std.container.dlist.DList!int.DList.remove (Range r) is not callable using argument types (Result)
> list.remove(res.take(1));
> Error: function std.container.dlist.DList!int.DList.remove (Range r) is not callable using argument types (Take!(Range))
> */
> }
>
> Are there any known workarounds besides linearRemove?
There is (unfortunatly) no support for takeOne in DList.
However, "linearRemove" is not a workaround or worst than remove. It is just that it accepts a wider range of input, when O(1) cannot be guaranteed. If you are operating with a range of length 1, then linearRemove is still O(1).
|
October 12, 2014 Re: DList!int.remove(range.takeOne) - workarounds? | ||||
---|---|---|---|---|
| ||||
Posted in reply to monarch_dodra | On Sunday, 12 October 2014 at 10:35:19 UTC, monarch_dodra wrote:
> On Sunday, 12 October 2014 at 09:45:22 UTC, Algo wrote:
>> DList seems to have an issue with remove:
>>
>> void main()
>> {
>> import std.container, std.range, std.algorithm;
>> auto list = DList!int([1, 2, 4, 6]);
>> auto res = find(list[], 2);
>> list.remove(res); //ok
>> /*
>> list.remove(res.takeOne);
>> Error: function std.container.dlist.DList!int.DList.remove (Range r) is not callable using argument types (Result)
>> list.remove(res.take(1));
>> Error: function std.container.dlist.DList!int.DList.remove (Range r) is not callable using argument types (Take!(Range))
>> */
>> }
>>
>> Are there any known workarounds besides linearRemove?
>
> There is (unfortunatly) no support for takeOne in DList.
>
> However, "linearRemove" is not a workaround or worst than remove. It is just that it accepts a wider range of input, when O(1) cannot be guaranteed. If you are operating with a range of length 1, then linearRemove is still O(1).
Thanks, linearRemove is fine, sorry for the misunderstanding
|
Copyright © 1999-2021 by the D Language Foundation