Andrei Alexandrescu:
One possibility is a function sortedChain that takes two or
more sorted ranges and returns a lazy sorted range. -- Andrei
Perhaps you are answering another thread and another problem. In
this problem there is only one range.
Bye,
bearophile
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
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?
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
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.
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
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
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
On 11/7/14 7:54 AM, bearophile wrote:
Max Klyga:
Ranges are not container. They are meant for traversing. If you want a
sorted range - use an underlying container that preserves ordering
(trees, heaps)
Let's asssume that the underlying container is a sorted built-in dynamic
array (that has
Jakob Ovrum:
Of course, positional container primitives like `insertFront`
and `insertBack` will not be supported.
Sometimes (or often) insertBack (or better the ~= operator) is
what I want, because I add items larger than ones already
present. insertBack has to verify the array is empty,
(This is a partial repost from a recent D.learn thread.)
In Phobos we have SortedRange and assumeSorted, but I do find
them not very good for a common enough use case.
The use case is to keep a sorted array, keep adding items to it
(adding larger and larger items at the end. Or sometimes
On 2014-11-07 14:11:30 +, bearophile said:
(This is a partial repost from a recent D.learn thread.)
In Phobos we have SortedRange and assumeSorted, but I do find them not
very good for a common enough use case.
The use case is to keep a sorted array, keep adding items to it (adding
Max Klyga:
Ranges are not container. They are meant for traversing. If you
want a sorted range - use an underlying container that
preserves ordering (trees, heaps)
Let's asssume that the underlying container is a sorted built-in
dynamic array (that has more locality than a tree and allows
Let's asssume that the underlying container is a sorted
built-in dynamic array (that has more locality than a tree and
allows very fast binary searches, unlike a heap).
An array, a sorted array, is a simple data structure that often
wins in terms of memory, simplicity, and efficiency.
On 11/07/2014 06:11 AM, bearophile wrote:
(This is a partial repost from a recent D.learn thread.)
In Phobos we have SortedRange and assumeSorted, but I do find them not
very good for a common enough use case.
The use case is to keep a sorted array, keep adding items to it (adding
larger and
Ali Çehreli:
If an array is sorted every time an element is added,
Items are most times added at the end, and they respect the
sortness of the whole array. The array never gets sorted.
On the other hand, array wins if the insertions are batched and
Insertions are not batched, and they
On Friday, 7 November 2014 at 14:11:32 UTC, bearophile wrote:
(This is a partial repost from a recent D.learn thread.)
In Phobos we have SortedRange and assumeSorted, but I do find
them not very good for a common enough use case.
The use case is to keep a sorted array, keep adding items to
17 matches
Mail list logo