-
-
Save jonpryor/330750 to your computer and use it in GitHub Desktop.
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
Range: | |
Min/Max rather than Start/End, better naming when dealing with non-contiguous ranges. | |
Start and end values are inclusive. | |
How enumeration works for stepping, etc is left to the class to decide, provide a static class with some standard implementations that use Math<T>. | |
Assumption is the main IRange<T> can be either contiguous or non-contiguous | |
Assumptions for SubRanges(): | |
No two sub-ranges overlap. | |
Each sub-range is atomic (ie contiguous). | |
Sub-ranges are returned in order of their Min value. | |
No sub-range is ever empty. | |
Min/Max throw an InvalidOperationException if IsEmpty == true. | |
interface IRange<T> : ISet<IRange<T>>, IEquatable<IRange<T>> { | |
T Min { get; } | |
T Max { get; } | |
bool IsEmpty { get; } | |
IEnumerable<IRange<T>> SubRanges(); | |
bool Contains(T value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment