Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-07-03 Thread Brad Anderson
On Sat, Jun 30, 2012 at 6:27 AM, bearophile bearophileh...@lycos.comwrote: Tobias Pankrath: But I would generally avoid SList. It's not good. And in general linked lists are quite overrated. On modern CPUs it's not easy to find situations where a linked list is better than a dynamic

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-07-02 Thread Christophe Travert
Have you had a look at dcollection ? http://www.dsource.org/projects/dcollections There is a doubly linked list implementation, with range and cursors (entities that have iterator functionalities).

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-07-01 Thread Dmitry Olshansky
On 30-Jun-12 18:25, Andrei Alexandrescu wrote: On 6/30/12 9:15 AM, Dmitry Olshansky wrote: On 30-Jun-12 15:35, Tobias Pankrath wrote: Say I have a forward range (for example, an SList[]). I would like to create a new range containing only the first 5 elements of that old range. How can I do

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-07-01 Thread monarch_dodra
On Saturday, 30 June 2012 at 23:51:42 UTC, Andrei Alexandrescu wrote: Yes. But now you're moving the goalposts because many of your arguments referred to SList. I'm sorry, that's not what I meant to do. The goal post was not moved, rather misplaced to begin with. Using SList for making my

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-07-01 Thread monarch_dodra
On Sunday, 1 July 2012 at 13:22:17 UTC, monarch_dodra wrote: Something like... inverseRangeBegin(R big, R small): Creates a range that begins where big starts, and ends where small starts. R must be at least bidirectional. small must be included inside big. From an implementation point of

Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread monarch_dodra
I've been enjoying my time with D's ranges, but something is nagging at me: If the range is not random access, then how does one create a sub-view of that range? Say I have a forward range (for example, an SList[]). I would like to create a new range containing only the first 5 elements of

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread Tobias Pankrath
Say I have a forward range (for example, an SList[]). I would like to create a new range containing only the first 5 elements of that old range. How can I do that? std.algorithm.take. But I would generally avoid SList.

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread monarch_dodra
On Saturday, 30 June 2012 at 11:35:07 UTC, Tobias Pankrath wrote: std.algorithm.take. But I would generally avoid SList. Thanks, but isn't that kind of a crutch solution? I mean: 1) It creates a new type, so any attempt to use it to modify an existing range becomes impossible: void main()

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread bearophile
Tobias Pankrath: But I would generally avoid SList. It's not good. And in general linked lists are quite overrated. On modern CPUs it's not easy to find situations where a linked list is better than a dynamic array or a chunked array (that is a dynamic array of pointers to arrays. It's

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread Dmitry Olshansky
On 30-Jun-12 15:35, Tobias Pankrath wrote: Say I have a forward range (for example, an SList[]). I would like to create a new range containing only the first 5 elements of that old range. How can I do that? std.algorithm.take. But I would generally avoid SList. Indeed. I'd be hard pressed

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread monarch_dodra
On Saturday, 30 June 2012 at 12:27:38 UTC, bearophile wrote: Tobias Pankrath: But I would generally avoid SList. It's not good. And in general linked lists are quite overrated. ... Bye, bearophile I appreciate the input, which I (mostly) agree with (I still love list's splice ability,

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread Andrei Alexandrescu
On 6/30/12 8:24 AM, monarch_dodra wrote: On Saturday, 30 June 2012 at 11:35:07 UTC, Tobias Pankrath wrote: std.algorithm.take. But I would generally avoid SList. Thanks, but isn't that kind of a crutch solution? I mean: 1) It creates a new type, so any attempt to use it to modify an

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread Andrei Alexandrescu
On 6/30/12 7:31 AM, monarch_dodra wrote: I've been enjoying my time with D's ranges, but something is nagging at me: If the range is not random access, then how does one create a sub-view of that range? Use take or takeExactly. Say I have a forward range (for example, an SList[]). I would

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread Andrei Alexandrescu
On 6/30/12 9:15 AM, Dmitry Olshansky wrote: On 30-Jun-12 15:35, Tobias Pankrath wrote: Say I have a forward range (for example, an SList[]). I would like to create a new range containing only the first 5 elements of that old range. How can I do that? std.algorithm.take. But I would

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread Monarch Dodra
On Saturday, 30 June 2012 at 14:22:06 UTC, Andrei Alexandrescu wrote: 2) The new range is defined as a fixed length from the beginning of the range, as opposed to start and finish points. If I were to insert new items into my Slist, the new range would just bump the top items out of its

Re: Creating a Sub-view of a non - RA (hasSlicing) range.

2012-06-30 Thread Andrei Alexandrescu
On 6/30/12 11:15 AM, Monarch Dodra wrote: On Saturday, 30 June 2012 at 14:22:06 UTC, Andrei Alexandrescu wrote: 2) The new range is defined as a fixed length from the beginning of the range, as opposed to start and finish points. If I were to insert new items into my Slist, the new range would