-
Notifications
You must be signed in to change notification settings - Fork 30
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
Complexity Requirements? #127
Comments
Another good question that I really ought to document somewhere! I actually changed this recently -- previously The new policy is as follows:
For sequences weaker than random access, I believe the constant-time Does that sound reasonable, or are there problematic cases I haven't considered? |
Which I guess means either |
To explain the seemingly asymmetric requirement that
and I don't want that to be needlessly slow. |
Yeah, We already have a |
So the theory that flux/include/flux/op/reverse.hpp Lines 61 to 64 in 1c128b5
This is... really not great :( |
Thanks Barry for asking tricky questions and making me think deeply about this! I think that silent, unexpected quadratic behaviour is absolutely unacceptable. That means that There are a few different options:
It turns out that for option 3, we don't actually need a new concept at all: instead, we can add a semantic requirement to the So the trade off is that in order to have a const-iterable Any thoughts @brevzin? |
Returning to this after a while... my latest thinking is as follows:
I think this would cover everything.... the only downside is that just about every adaptor would need to do something like |
Thought I'd follow up my last question with another question.
I see that in flux,
filter
's implementation offirst
just does afind_if
:flux/include/flux/op/filter.hpp
Lines 50 to 53 in 1c128b5
So is the intent that there is no complexity requirement on
first
(and potentiallylast
andis_last
)?My go-to example for the complexity requirements in Ranges is
r.drop_last_while(p).stride(2)
, but in flux actually I think it's enough to ask aboutr.drop_last_while(p)
even by itself (which flux doesn't have yet, but don't treat this as a request to go rush to add it). If theflux::is_last
check is going to be implemented as afind_if
(or, whatever,find_last_if_not
) then iterating over this sequence becomes quadratic time:flux/include/flux/op/for_each_while.hpp
Lines 24 to 28 in 1c128b5
The text was updated successfully, but these errors were encountered: