- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 639
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
Iterate once to create two iterators in partition #2577
Merged
danieldietrich
merged 15 commits into
vavr-io:master
from
mincong-h:issue-2559-partition
May 23, 2020
+360
−31
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e305cb2
Reproduce the problem
mincong-h 1d25766
Iterate once to create two iterators in partition
mincong-h 7c52962
Avoid using io.vavr.collection.Stream
mincong-h 42117bf
Test behavior of `partition` on different classes
mincong-h 5829a64
Test that Stream.partition() is lazy
mincong-h 10ff3d4
Create Iterator.duplicate() and add tests
mincong-h 7316baa
Change the implementation of Iterator.partition()
mincong-h 0dce6b9
Fix Set
mincong-h d486446
Fix Map
mincong-h b75a1b6
Fix Multimap
mincong-h 64be4e4
Move duplicate to IteratorModule
mincong-h 87e5bab
Remove synchronized keyword
mincong-h 17c6f4c
Remove hashCode and equals
mincong-h ba54ca5
Avoid using isEqualTo
mincong-h 4481b97
Remove redundant tests
mincong-h File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Avoid using io.vavr.collection.Stream
commit 7c52962699131f07cdb03e5b3e455766a07c3a70
There are no files selected for viewing
This file contains 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
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.
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 do not know if it is an issue here, but...
This solution is filtering eagerly and previous solution was filtering lazily.
If we would like to keep the same behaviour there is an option of creating a memoized predicate and then use it during filtering, e.g.
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 found that my solution with memoized predicate will not work in case when a mutable object mutates to the value that corresponds to another object to be filtered. Then another object is not evaluated but taken from cache with wrong result for it.
Example test:
Where
In this case the result of evaluation
MutableInteger.of(1).incrementAndCheckGreaterThan(2)
is put into cache with entryMutableInteger.of(2) -> false
.Then when the next object from set
MutableInteger.of(2)
is filtered and it is found in the cache and evaluated tofalse
. While normally it would evaluate toMutableInteger.of(3) -> true
.But the question stays whether we want to keep the partitioning lazy or not.
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.
This is a bit too technical for me... Maybe @danieldietrich can have an answer about it.