Detection of One Sorted Sequence Being a Subset of Another #234
+809
−0
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.
Description
This function is an adaptation of the
includes
function from C++. This pull request is a sequel to "Detection of How One Sorted Sequence Includes Another" (#38).I started with a new version of the
Inclusion
type and thesortedOverlap
function from Pull #38. I added another function,includes
, that calls the overlap detector then translates the exact overlap degree to a simpleBool
result.Then I figured that no one actually cares about the precise overlapping factor. So the precise-overlap function and support type were removed, and its code was moved into
includes
directly. Since a general answer wasn't required, I could add short-circuit logic.Detailed Design
One primary function extends
Sequence
to test if a given sequence is a subset of the receiver, assuming both are sorted according to the given predicate. (The given sequence's elements need not be contiguous in the receiver.) The variant function removes the predicate parameter for a default of the less-than operator (<
), at the cost of requiringComparable
conformance.Documentation Plan
Both introductory documentation and a guide were added.
Test Plan
A test file was added.
Source Impact
The functions are an additive change, not otherwise affecting the API.
Checklist