Re: Double link list

2018-02-24 Thread Joel via Digitalmars-d-learn
On Saturday, 24 February 2018 at 09:48:13 UTC, Joel wrote: I'm trying some code for practice, but it isn't working properly - it prints just one number when printing in reverse. [snip] Thanks guys. And I got it working with 'if (head is tail)' etc.

Re: Double link list

2018-02-24 Thread ag0aep6g via Digitalmars-d-learn
On 02/24/2018 11:26 AM, TheFlyingFiddle wrote: On Saturday, 24 February 2018 at 09:48:13 UTC, Joel wrote: [...] void popFront() { head = head.next;  if (head !is null) head.prev = null; } void popBack() { tail = tail.prev; if (tail !is null) tail.next = null; } Head and tail will point to th

Re: Double link list

2018-02-24 Thread Alex via Digitalmars-d-learn
On Saturday, 24 February 2018 at 09:48:13 UTC, Joel wrote: I'm trying some code for practice, but it isn't working properly - it prints just one number when printing in reverse. [...] the first writeln destroys the range via popFront, I think. As if you comment it out, the writeln with retro

Re: Double link list

2018-02-24 Thread TheFlyingFiddle via Digitalmars-d-learn
On Saturday, 24 February 2018 at 09:48:13 UTC, Joel wrote: I'm trying some code for practice, but it isn't working properly - it prints just one number when printing in reverse. I think the problem is here: void popFront() { head = head.next; if (head !is null) head.prev = null; } void pop

Double link list

2018-02-24 Thread Joel via Digitalmars-d-learn
I'm trying some code for practice, but it isn't working properly - it prints just one number when printing in reverse. ''' void main() { import std.stdio, std.algorithm, std.range, std.conv; struct List(T) { class Node { T value;