Lazily compute Iterator len#295
Merged
Kerollmops merged 1 commit intoRoaringBitmap:mainfrom Oct 30, 2024
Merged
Conversation
d38a11a to
55f5f85
Compare
Kerollmops
requested changes
Oct 18, 2024
Member
There was a problem hiding this comment.
Excellent implementation of the option 1. Also, when you said that it is O(n), this n is the number of containers, so it's ok and even only called when calling size_hint, so that's pretty good.
I'm just thinking that when you call collect into a Vec, for example, the implementation will call size_hint 🤔 Anyway, it's still much better.
I let you rebase on main, flatten in a single commit and I'll merge, thank you again! Nice work 👌
This means the price of visting every container is only paid when needed: e.g. when calling `.collect()` This adds more efficent overrides for `count`, `nth` and `nth_back`, and implements `FusedIterator`
55f5f85 to
820b270
Compare
Member
Author
|
@Kerollmops Believe this is ready |
Kerollmops
approved these changes
Oct 30, 2024
Member
Kerollmops
left a comment
There was a problem hiding this comment.
Wonderful addition! Thank you! Merging 🙏
This was referenced Oct 30, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lazily compute the length of an iterator, rather than doing so eagerly at creation time.
Additionally, add more efficient implementations of
count,nth, andnth_back.This required somewhat manually reimplementing
std::iter::Flatten, but this is something we'll need to do anyway for #290 / #287.This is currently built on top of #292, (so the PR currently includes commits from that PR too)
Fixes #294