-
Notifications
You must be signed in to change notification settings - Fork 440
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
Merging Sorted Sequences #43
Open
CTMacUser
wants to merge
9
commits into
apple:main
Choose a base branch
from
CTMacUser:merge
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+1,529
−0
Conversation
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 a type describing the subsets that can be taken of the merger of two sets. Add a type that is a sequence that takes two sequences, a predicate that both sources are sorted along, and a merger-subset state, and vends the seleected subset of the merger which is also sorted. Add an extension method to sequences that takes another sequence, ordering predicate, and subset selection and returns an array with the merged sequence. Add lazy variants of this method. Add overloads that default the ordering predicate to the standard less-than operator.
Implement the property that underreports the element count, built by combining the sources' counts. Implement the method that briefly gives access to the elements' buffer, non-NIL only when at most one source sequence needs to be used. Implement the secret method that optimizes the element-containment test, built by combining the sources' search results.
Add a test that will go through all of the code paths of the eager method to merge sorted sequences.
Replace the two private methods used to implement the throwing version of element iteration (for the iterator type) with a single private method that returns both sources' elements for a corresponding pair, using a custom return type. It's not only simpler, but should help in implementing merged sorted collections.
Remove a "which-one" flag from a case of an internal accounting enumeration type. It was never actually used.
Augment the type used to present the sorted merger of two sorted sequences to conditionally conform to Collection when both sources are also collections. This involves new types to represent Index, Indices, and Indices.Iterator. Like the eager merger algorithm, it reuses the lazy iteration code.
Add test to merge sorted sequences with a custom predicate that is not the standard less-than operator. This predicate does not use all of the operands' members, so the source of a particular element can be tested.
mdznr
reviewed
Oct 29, 2021
@@ -0,0 +1,125 @@ | |||
# Permutations |
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.
Suggested change
# Permutations | |
# MergeSorted |
4 tasks
This is now obsolete from my next attempt at [#184]. |
4 tasks
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.
This library adapts the C++ algorithm functions that take two sorted sequences and returns an also-sorted sequence that represents the set-difference, intersection, union, etc.. Instead of separate functions for each operation, the desired operation is selected by an enumeration value. (All the operations follow the same algorithm.) This includes an operation to do the general merge sort!
Checklist