Skip to content

Library of operations for interval type. There are operations of comparisons for low and upper boundary and for entri interval, operation to check interval for containing point etc.

License

Notifications You must be signed in to change notification settings

RetailRocket/Interval.Operations

Repository files navigation

.NET Core NuGet version

Interval.Operations

Library of operations for interval type from Interval Library. There are operations of comparisons for low and upper boundary and for entry interval, operation to check interval on containing point etc.

Usage

Contains Point Operation

var openInterval = new Interval<int>(
    lowerBound: new OpenLowerBound<int>(0),
    upperBound: new OpenUpperBound<int>(10));

openInterval.Contains(
    point: 5,
    comparer: Comparer<int>.Default) // => true

openInterval.Contains(
    point: 11,
    comparer: Comparer<int>.Default) // => false

Different Comparer

var interval = new Interval.Interval<string>(
    lowerBound: new OpenLowerBound<string>("a"),
    upperBound: new OpenUpperBound<string>("z"));

interval.Contains(
    point: "B",
    comparer: StringComparer.Ordinal) // => false

interval.Contains(
    point: "B",
    comparer: StringComparer.OrdinalIgnoreCase); // => false

Get Boundaries Points

new Interval<int>(
        lowerBound: new ClosedLowerBound<int>(1),
        upperBound: new ClosedUpperBound<int>(2))
    .GetBoundariesPoints(); // -> [1,2]

Boundary Comparer

You can compare deferent types of lower or upper boundary

new LowerBoundComparer<int>(
        comparer: Comparer<int>.Default)
    .Compare(
        left: new ClosedLowerBound<int>(10),
        right: new ClosedLowerBound<int>(11)); // -> 1

The same for upper boundary

new UpperBoundComparer<int>(
        comparer: Comparer<int>.Default)
    .Compare(
        left: new ClosedUpperBound<int>(10),
        right: new ClosedUpperBound<int>(11)); // -> 1

Interval Comparer

var intervalA = new Interval.Interval<int>(
    lowerBound: new ClosedLowerBound<int>(0),
    upperBound: new ClosedUpperBound<int>(10));

var intervalB = new Interval.Interval<int>(
    lowerBound: new ClosedLowerBound<int>(1),
    upperBound: new ClosedUpperBound<int>(9));

new IntervalComparer<int>(
        comparer: Comparer<int>.Default)
    .Compare(
        left: intervalA,
        right: intervalB); // -> -1

About

Library of operations for interval type. There are operations of comparisons for low and upper boundary and for entri interval, operation to check interval for containing point etc.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages