Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
October 13, 2018 ported a sortable list from my old C code | ||||
---|---|---|---|---|
| ||||
https://run.dlang.io/gist/b8b03ce3246951b5356db064ab68b22e its a bit fugly at the moment and I want to use something other than a void pointer (any?) (the whole thing was very pointer centric as everything was malloc'd...) I'm not entirely sure it would benefit from turning into a class ? Does anyone has any ideas on improving this sortable list |
October 13, 2018 Re: ported a sortable list from my old C code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Codifies | On Saturday, 13 October 2018 at 11:11:41 UTC, Codifies wrote:
> https://run.dlang.io/gist/b8b03ce3246951b5356db064ab68b22e
>
> its a bit fugly at the moment and I want to use something other than a void pointer (any?) (the whole thing was very pointer centric as everything was malloc'd...)
>
> I'm not entirely sure it would benefit from turning into a class ?
>
> Does anyone has any ideas on improving this sortable list
Something is wrong with the link :(
|
October 13, 2018 Re: ported a sortable list from my old C code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Codifies | On Saturday, 13 October 2018 at 11:11:41 UTC, Codifies wrote:
> Does anyone has any ideas on improving this sortable list
Yes. Use an array. No, really, use an array. Now, really, use an array.
If reallocations while building your paths become a problem, you can write a deque (bucket array) or a dlist. But still, afterwards just convert it to array and use that.
|
October 13, 2018 Re: ported a sortable list from my old C code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alex | On Saturday, 13 October 2018 at 11:28:08 UTC, Alex wrote:
> On Saturday, 13 October 2018 at 11:11:41 UTC, Codifies wrote:
>> https://run.dlang.io/gist/b8b03ce3246951b5356db064ab68b22e
>>
>> its a bit fugly at the moment and I want to use something other than a void pointer (any?) (the whole thing was very pointer centric as everything was malloc'd...)
>>
>> I'm not entirely sure it would benefit from turning into a class ?
>>
>> Does anyone has any ideas on improving this sortable list
>
> Something is wrong with the link :(
gutted .... anywhere else I can post it?
|
October 13, 2018 Re: ported a sortable list from my old C code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Alex | On Saturday, 13 October 2018 at 11:28:08 UTC, Alex wrote: > Something is wrong with the link :( https://dpaste.dzfl.pl/af9e6f6ce53e |
October 13, 2018 Re: ported a sortable list from my old C code | ||||
---|---|---|---|---|
| ||||
Posted in reply to Codifies | On 10/13/18 7:11 AM, Codifies wrote:
> https://run.dlang.io/gist/b8b03ce3246951b5356db064ab68b22e
>
> its a bit fugly at the moment and I want to use something other than a void pointer (any?) (the whole thing was very pointer centric as everything was malloc'd...)
>
> I'm not entirely sure it would benefit from turning into a class ?
>
> Does anyone has any ideas on improving this sortable list
Yes, use mergesort instead of bubble sort. As I said, I will attempt to add sorting to Phobos for slist and dlist.
-Steve
|
Copyright © 1999-2021 by the D Language Foundation