Talk:Sorting algorithms/Strand sort: Difference between revisions
Content added Content deleted
No edit summary |
(→D Entry: possible solution) |
||
Line 15: | Line 15: | ||
} |
} |
||
}</lang>[[User:Bearophile|bearophile]] |
}</lang>[[User:Bearophile|bearophile]] |
||
::: Well, I'll give it my best try. In my opinion the problem lies with the removeFront / removeBack functions. They don't set the _first._prev / _last._next pointers to null. The following (adjusted) code seems to work. What do you think? <lang d> void removeFront() |
|||
{ |
|||
enforce(_first); |
|||
_first = _first._next; |
|||
if (_first is null) |
|||
{ |
|||
_last = null; |
|||
} |
|||
else |
|||
{ |
|||
_first._prev = null; |
|||
} |
|||
} |
|||
void removeBack() |
|||
{ |
|||
enforce(_last); |
|||
_last = _last._prev; |
|||
if (_last is null) |
|||
{ |
|||
_first = null; |
|||
} |
|||
else |
|||
{ |
|||
_last._next = null; |
|||
} |
|||
} |
|||
</lang> |