ComparableIntervals 2.0.0
dotnet add package ComparableIntervals --version 2.0.0
NuGet\Install-Package ComparableIntervals -Version 2.0.0
<PackageReference Include="ComparableIntervals" Version="2.0.0" />
paket add ComparableIntervals --version 2.0.0
#r "nuget: ComparableIntervals, 2.0.0"
// Install ComparableIntervals as a Cake Addin #addin nuget:?package=ComparableIntervals&version=2.0.0 // Install ComparableIntervals as a Cake Tool #tool nuget:?package=ComparableIntervals&version=2.0.0
ComparableIntervals
A library which helps doing common operations, such as union, intersection or complement, on intervals of
IComparable
types.
Disclaimer: I've created this library for a very specific application I'm developing in my company. I've tried to make it more generic than I needed, but eventually it may be not as generic as it should be. If this library fits your needs, you're welcome to use it, but if you need more functionalities, please don't ask for them. In any case, any pull request is appreciated.
Getting started
Every method and class in this library is documented inline, but here are a few hints to get started.
Create two Interval
s of type int
:
var interval1 = Interval<int>.Closed(1, 5);
var interval2 = Interval<int>.Open(3, 7);
Perform some operations on them:
var intersection = interval1.Intersection(interval2); // => (3, 5]
var Union = interval1.Union(interval2); // => [1, 7)
Perform operations on lists of intervals:
var intervals1 = new List<Interval<int>> {
Interval<int>.ClosedOpen(-2, 2),
Interval<int>.OpenClosed(4, 8)
};
var intervals2 = new List<Interval<int>> {
Interval<int>.Closed(0, 6),
};
var intersection = Intervals.Intersection(intervals1, intervals2); // => [0, 2), (4, 6]
var union = Intervals.Union(intervals1, intervals2); // => [-2, 8]
var complement = Intervals.Complement(intervals1); // => (-∞, -2), [2, 4], (8, ∞)
Library structure
This library library exposes a few objects to build and compute intervals.
struct Bound<T>
: represents a bound of type T
, where T : IComparable
.
A bound may be open, closed, or may represent negative or positive infinity. Methods to create those types of bounds
are provided.
class Interval<T>
: represents an interval of type T
, where T : IComparable
.
An interval is an entity with an upper bound and a lower bound. To create a closed, open, open-close, closed-open
interval, one of the provided methods may be used, otherwise it can be created providing its bounds.
Operations on an interval (such as union and intersection) are provided as extension methods, so that they can be
called on an instance of an interval or in a static way.
static class Intervals
: a class which provides static methods to operate on collections of intervals.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net40 is compatible. net403 was computed. net45 is compatible. net451 is compatible. net452 is compatible. net46 is compatible. net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.0
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETFramework 4.5.1
- No dependencies.
-
.NETFramework 4.5.2
- No dependencies.
-
.NETFramework 4.6
- No dependencies.
-
.NETFramework 4.6.1
- No dependencies.
-
.NETFramework 4.7.2
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.0 | 980 | 9/16/2020 |