November 10, 2014 Re: Keeping a dynamic sorted range | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Monday, 10 November 2014 at 02:19:33 UTC, Andrei Alexandrescu wrote: > One possibility is a function sortedChain that takes two or more sorted ranges and returns a lazy sorted range. -- Andrei setUnion? http://dlang.org/phobos/std_algorithm.html#.setUnion | |||
November 10, 2014 Re: Keeping a dynamic sorted range | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Vladimir Panteleev | On 11/10/14 5:06 AM, Vladimir Panteleev wrote:
> On Monday, 10 November 2014 at 02:19:33 UTC, Andrei Alexandrescu wrote:
>> One possibility is a function sortedChain that takes two or more
>> sorted ranges and returns a lazy sorted range. -- Andrei
>
> setUnion?
>
> http://dlang.org/phobos/std_algorithm.html#.setUnion
That's right! -- Andrei
| |||
November 10, 2014 Re: Keeping a dynamic sorted range | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Andrei Alexandrescu:
>> http://dlang.org/phobos/std_algorithm.html#.setUnion
>
> That's right! -- Andrei
Still, this is very far from what I asked for...
Bye,
bearophile
| |||
November 10, 2014 Re: Keeping a dynamic sorted range | ||||
|---|---|---|---|---|
| ||||
Posted in reply to bearophile | It doesn't really address your question, but if you're mostly inserting you may want to store it as a heap and sort before lookup. | |||
November 10, 2014 Re: Keeping a dynamic sorted range | ||||
|---|---|---|---|---|
| ||||
Posted in reply to bearophile | To address your question a bit more fully, it seems like this is something the range proposal for C++ is better suited for. Then appending would just be a special case of inserting at a specific position. I've got to say, if I had the time I'd implement the C++ ranges in D. They seem more powerful and easier to use. | |||
November 10, 2014 Re: Keeping a dynamic sorted range | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Sean Kelly | On 11/10/14 7:42 AM, Sean Kelly wrote:
> To address your question a bit more fully, it seems like this is
> something the range proposal for C++ is better suited for. Then
> appending would just be a special case of inserting at a specific
> position. I've got to say, if I had the time I'd implement the C++
> ranges in D. They seem more powerful and easier to use.
What would be their advantages? -- Andrei
| |||
November 10, 2014 Re: Keeping a dynamic sorted range | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Monday, 10 November 2014 at 19:59:02 UTC, Andrei Alexandrescu wrote: > On 11/10/14 7:42 AM, Sean Kelly wrote: >> To address your question a bit more fully, it seems like this is >> something the range proposal for C++ is better suited for. Then >> appending would just be a special case of inserting at a specific >> position. I've got to say, if I had the time I'd implement the C++ >> ranges in D. They seem more powerful and easier to use. > > What would be their advantages? The ability to denote a position within a range is an important facet of some algorithms, such as rotate. For example, see: https://ericniebler.github.io/std/wg21/D4128.html#iterator-operations-are-primitive | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply