SortedRange and new docs for std.container

2010-09-08 Thread Andrei Alexandrescu
Hello, I just added SortedRange as discussed a while ago in this newsgroup. I think it turned out pretty neat. Generally the range abstraction is turning out to be very solid. To get a SortedRange object for a given range r either call sort(r) if you want to sort one, or assumeSorted(r) if

Re: SortedRange and new docs for std.container

2010-09-08 Thread dsimcha
== Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article > Hello, > I just added SortedRange as discussed a while ago in this newsgroup. I > think it turned out pretty neat. Generally the range abstraction is > turning out to be very solid. > To get a SortedRange object for a giv

Re: SortedRange and new docs for std.container

2010-09-08 Thread Andrei Alexandrescu
On 9/8/10 9:21 CDT, dsimcha wrote: == Quote from Andrei Alexandrescu (seewebsiteforem...@erdani.org)'s article Hello, I just added SortedRange as discussed a while ago in this newsgroup. I think it turned out pretty neat. Generally the range abstraction is turning out to be very solid. To get a

Re: SortedRange and new docs for std.container

2010-09-08 Thread bearophile
Andrei: > I've also fixed Zip (finally!) to get rid of a couple of dirty tricks. > It turns out that front()/front(v)/moveFront() are a correct way to > abstract proxy ranges like Zip is. In this changeset: http://www.dsource.org/projects/phobos/changeset/1968 I see code as: auto arr2 = t.fiel

Re: SortedRange and new docs for std.container

2010-09-08 Thread Andrej Mitrovic
I don't want to hijack the topic, but can I ask a question? In the Phobos docs I often see this kind of code: assert(equal(radial(a), [ 3, 4, 2, 5, 1 ][])); What is the purpose of the extra square brackets after the array literal? Because the code works both with and without them. On Wed, Sep 8

Re: SortedRange and new docs for std.container

2010-09-08 Thread Andrei Alexandrescu
On 9/8/10 12:06 CDT, Andrej Mitrovic wrote: I don't want to hijack the topic, but can I ask a question? In the Phobos docs I often see this kind of code: assert(equal(radial(a), [ 3, 4, 2, 5, 1 ][])); What is the purpose of the extra square brackets after the array literal? Because the code wo

Re: SortedRange and new docs for std.container

2010-09-08 Thread Andrei Alexandrescu
On 9/8/10 11:52 CDT, bearophile wrote: Andrei: I've also fixed Zip (finally!) to get rid of a couple of dirty tricks. It turns out that front()/front(v)/moveFront() are a correct way to abstract proxy ranges like Zip is. In this changeset: http://www.dsource.org/projects/phobos/changeset/1968

Re: SortedRange and new docs for std.container

2010-09-08 Thread Jesse Phillips
Andrei Alexandrescu Wrote: > On 9/8/10 12:06 CDT, Andrej Mitrovic wrote: > > I don't want to hijack the topic, but can I ask a question? > > > > In the Phobos docs I often see this kind of code: > > > > assert(equal(radial(a), [ 3, 4, 2, 5, 1 ][])); > > > > What is the purpose of the extra square

Re: SortedRange and new docs for std.container

2010-09-08 Thread Andrej Mitrovic
Wow, you can actually interpret code on that site. Nice. I wonder how safe that is for them.. On Wed, Sep 8, 2010 at 9:47 PM, Jesse Phillips wrote: You can use literals to create static arrays by giving the type you want. > > http://ideone.com/qInPu > > The default was changed because Phobos was

Re: SortedRange and new docs for std.container

2010-09-08 Thread bearophile
Jesse Phillips: > The default was changed because Phobos was littered with [...][] in all the > tests... Andrei must have gotten annoyed. :) The default was changed because most times you want a dynamic array. (On the other hand I don't love the amount of memory allocations caused by the current

Re: SortedRange and new docs for std.container

2010-09-08 Thread Tomek Sowiński
Dnia 08-09-2010 o 15:55:30 Andrei Alexandrescu napisał(a): I just added SortedRange as discussed a while ago in this newsgroup. I think it turned out pretty neat. Generally the range abstraction is turning out to be very solid. To get a SortedRange object for a given range r either call

Re: SortedRange and new docs for std.container

2010-09-09 Thread Tomek Sowiński
Tomek Sowiński napisał: > 2. Could makeIndex() also return SortedRange? The predicate should be > morphed of course to account for dereferencing. Or better: SortedRange's underlying range should account for dereferencing and leave the predicate intact. Tomek