-
Notifications
You must be signed in to change notification settings - Fork 112
implement Iter::group_by #1998
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
base: main
Are you sure you want to change the base?
implement Iter::group_by #1998
Conversation
Potentially inefficient array allocation in chunk_byCategory Nested closure complexity in chunk_by implementationCategory Potential memory leak in chunk_by error handlingCategory |
Pull Request Test Coverage Report for Build 6456Details
💛 - Coveralls |
assert_eq!(groups, [ | ||
(25, ["Alice", "Bob"]), | ||
(30, ["Charlie"]), | ||
(35, ["Dave"]), |
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.
Why there's two 30
? It's not expected from users.
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 the same principle as the test above, it's generating a new group every time the value of the key function changes.
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.
I have doubt about the type signature. I'm not quite sure whether we should have Iter
inside Iter
. It looks kind of weird to me. Maybe Iter[(Key, Array[Value])]
is enough. I'm also not certain with the semantics. Are we expecting group_by
to be an iterator that merges the adjacent items or are we expecting it to group everything visited, in which case we should have Map[Key, Array[Value]]
as result.
I think |
This one was my reference for the implementation, but I probably should've questioned beforehand :) |
What I had in mind was
Seems we all have different understanding of what |
It was actually my initial thought, but after reading a bit about iterators, that approach made sense. No problem though, will come up with the new version soon |
FTR The original implementation may be renamed with a more proper name such as:
Though some uses
Also notice that
|
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.
For better performance, we may need #1965
It seems to me that either |
There's |
4db2363
to
9b195a1
Compare
Can we keep the |
Fixes #1201