New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new lazy range: merge() #3315
Conversation
@@ -8647,3 +8647,237 @@ if (is(typeof(fun) == void) || isSomeFunction!fun) | |||
|
|||
auto r = [1, 2, 3, 4].tee!func1.tee!func2; | |||
} | |||
|
|||
template CommonElementType(Rs...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this package-qualified? If not, keep it package
for now because it's not supposed to be public (not documented). Let's decide in a future pull whether this belongs to std.traits (or possibly std.range).
Great work! Please address these nits and then let's get this in. Thank you, really impressed! |
How do we assert that the inputs are sorted according to the template parameter package alias isSortedRange(R) = isInstanceOf!(SortedRange, R); as package alias isSortedRangeAs(R, alias pred) = isInstanceOf!(SortedRange, pred, R); but this is not currently supported by Could |
Added propagation of infiniteness. |
@andralex Ping :) |
Yah I think you use |
@nordlow ping :) |
foreach (ref e; m)
{
e = 100;
} has currently no sideeffect on
"Yah I think you use auto ref with front and back in a subsequent diff." I've always used
How do we assert that the inputs are sorted according to the template parameter |
|
||
void popFront() | ||
{ | ||
final switch (_lastFrontIndex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably a bug that final switch is allowed here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
roundRobin
uses the final switch
pattern aswell.
If I remove the final
I get
Error: switch statement without a default; use 'final switch' or add 'default: assert(0);' or add 'default: break;'
I think we should leave it as is and remove all uses of final switch
in one go if this is wrong.
Hello, |
Is see two directions here:
In both cases there is one problem however; what to do about the fact that @lomereiter I don't under stand why mention duplicate elements; |
@nordlow I'm not sure what the matter with that loop is without context. It should work if all ranges have the same type. I'll pull this because that matter doesn't seem to block it. If anything fishy, please submit a bug report as a runnable program using the already-pulled merge(). |
Auto-merge toggled on |
@nordlow I mentioned duplicates because you referred to std::merge from STL, and std::set_union performs deduplication. |
@andralex Shouldn't I have done a rebase first? |
@lomereiter Why doesn't |
Ok, great. Then I know. Thanks @andralex for a quick response! Made my day :) |
Wait, what are the commonalities and distinctions among |
The idea behind Sadly it seems to me we should not add |
I see the following directions forward:
I vote for the second alternative. |
So, any thoughts on this? The release is looming. If anything we should revert this pull or de-document the function to buy more time. |
As already mentioned above I stand with the second alternative. @andralex? |
Ok. |
@nordlow would you have time to revive your work from the dead and incorporate the additional capabilities into merge? |
I'm waiting for a decision from @andralex on which of the 3 directions to go (see above). Shall I give a ping? Update: Ahh, I just saw your work on #4249 (comment) I'll look into it. Update: @wilzbach Is deduplication of consecutive elements the only thing that is missing in this PR? If so should we just add a parameter |
Are you referring to adding a parameter
You now have (I have tried to deprecate public structs before, it's really not worth it)
The deprecation warning is now triggered for
Breakage needs to be avoided. |
Ok. AFAICT the plan is:
Is this correct? Further, I'm all for making To resurrect this work, is a new PR the way to go? |
I am not sure what you mean with removing features. I had a quick look (from my phone) and I think your PR contains at least these goodies:
So yeah - you can basically paste it over the existing
The symbol
Yes please (there is no way to reopen a merged PR) |
In compliance with C++ STL
std::merge
: http://en.cppreference.com/w/cpp/algorithm/mergebut variadic and with bidirectional access, of course! :)
Implementation is a tweak of
roundRobin
extended to support bidirectional access iff all its input ranges does.Respects
CommonType
of theElementTypes
of the input ranges.Propagates infiniteness if any of the inputs is infinite.
CommonElementType
in std.traits?pred
?isSortedRange
instd/range/primitives.d
?popFront
for a large number of parameters. But that's perhaps outside the scope of this implementation.