Re: Remove element from DList

2012-10-09 Thread Steven Schveighoffer
On Tue, 09 Oct 2012 13:51:09 -0400, Jonathan M Davis wrote: On Tuesday, October 09, 2012 10:29:46 Steven Schveighoffer wrote: dcollections does not have singly-linked lists. My mistake. I thought that you had said that it did in previous discussions on this topic. I decided early on t

Re: Remove element from DList

2012-10-09 Thread Jonathan M Davis
On Tuesday, October 09, 2012 10:29:46 Steven Schveighoffer wrote: > dcollections does not have singly-linked lists. My mistake. I thought that you had said that it did in previous discussions on this topic. - Jonathan M Davis

Re: Remove element from DList

2012-10-09 Thread Steven Schveighoffer
On Sun, 07 Oct 2012 05:15:05 -0400, Jonathan M Davis wrote: On Sunday, October 07, 2012 10:09:06 Russel Winder wrote: Removal from a singly-linked list can be O(1) as well, it depends whether you are deleting using an iterator in progress. IIRC that dcollections' singly-linked list is like

Re: Remove element from DList

2012-10-07 Thread Andrei Alexandrescu
On 10/7/12 5:15 AM, Jonathan M Davis wrote: On Sunday, October 07, 2012 10:09:06 Russel Winder wrote: Removal from a singly-linked list can be O(1) as well, it depends whether you are deleting using an iterator in progress. IIRC that dcollections' singly-linked list is like this, but std.conta

Re: Remove element from DList

2012-10-07 Thread Jonathan M Davis
On Sunday, October 07, 2012 12:54:00 Russel Winder wrote: > Is there a rationale for having multiple implementation of the same data > structure, one in druntime and the other in std.container? Which data structure are you takling about? I'm not aware of anything in std.container being in druntim

Re: Remove element from DList

2012-10-07 Thread Russel Winder
On Sun, 2012-10-07 at 02:15 -0700, Jonathan M Davis wrote: […] > IIRC that dcollections' singly-linked list is like this, but > std.container.SList definitely isn't. I'm not a big fan of singly-linked > lists > in the first place and tend to think that they're useless, but > std.container's >

Re: Remove element from DList

2012-10-07 Thread Jonathan M Davis
On Sunday, October 07, 2012 10:09:06 Russel Winder wrote: > Removal from a singly-linked list can be O(1) as well, it depends > whether you are deleting using an iterator in progress. IIRC that dcollections' singly-linked list is like this, but std.container.SList definitely isn't. I'm not a big

Re: Remove element from DList

2012-10-07 Thread Russel Winder
On Sat, 2012-10-06 at 19:42 -0700, Jonathan M Davis wrote: […] > singly-linked lists and doubly-linked lists are completely different beasts. > A > singly-linked list can't do it sanely, because it has to traverse the list to > find the previous node so that it adjust the links. A node in a doub

Re: Remove element from DList

2012-10-06 Thread Jonathan M Davis
On Sunday, October 07, 2012 06:54:25 cal wrote: > > On Sunday, 7 October 2012 at 01:14:48 UTC, Jonathan M Davis > > wrote: > > Regardless, it's a bug that normal remove doesn't work with the > > result of take. > > I guess this is also true of insertAfter and co? Should they > accept the result of

Re: Remove element from DList

2012-10-06 Thread cal
On Sunday, 7 October 2012 at 01:14:48 UTC, Jonathan M Davis wrote: Regardless, it's a bug that normal remove doesn't work with the result of take. I guess this is also true of insertAfter and co? Should they accept the result of take? (Currently they don't)

Re: Remove element from DList

2012-10-06 Thread cal
On Sunday, 7 October 2012 at 02:54:44 UTC, Jonathan M Davis wrote: On Sunday, October 07, 2012 04:14:58 cal wrote: On Sunday, 7 October 2012 at 01:14:48 UTC, Jonathan M Davis wrote: > The correct way is to use find combined with take (which is > what you're doing, > except that you're not using

Re: Remove element from DList

2012-10-06 Thread Jonathan M Davis
On Sunday, October 07, 2012 04:14:58 cal wrote: > On Sunday, 7 October 2012 at 01:14:48 UTC, Jonathan M Davis wrote: > > The correct way is to use find combined with take (which is > > what you're doing, > > except that you're not using find). So, something like this > > should work > > > > void m

Re: Remove element from DList

2012-10-06 Thread cal
On Sunday, 7 October 2012 at 01:14:48 UTC, Jonathan M Davis wrote: The correct way is to use find combined with take (which is what you're doing, except that you're not using find). So, something like this should work void main() { auto list = DList!int([1,2,3,4]); list.remove(find(lis

Re: Remove element from DList

2012-10-06 Thread Jonathan M Davis
On Saturday, October 06, 2012 23:27:31 cal wrote: > I'd like to remove a single element from a std.container.DList. > For that I need a range, but I'm not sure how to get a single > element 'range'. > > I thought something like this might work: > > auto list = DList!int([1,2,3,4]); > auto r = lis

Re: Remove element from DList

2012-10-06 Thread cal
On Saturday, 6 October 2012 at 21:39:29 UTC, cal wrote: I'd like to remove a single element from a std.container.DList. For that I need a range, but I'm not sure how to get a single element 'range'. I thought something like this might work: auto list = DList!int([1,2,3,4]); auto r = list[]; w