Skip to content

Commit

Permalink
feat: Add method contains in Interval
Browse files Browse the repository at this point in the history
  • Loading branch information
sandre58 committed Jul 5, 2024
1 parent 69e0b6e commit 91bf01a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/MyNet.Utilities/Sequences/Interval.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ private void SetIntervalInternal(T start, T end)

public bool Contains(T value) => value.CompareTo(Start) >= 0 && value.CompareTo(End) <= 0;

public bool Contains(Interval<T> interval) => interval.Start.CompareTo(Start) >= 0 && interval.End.CompareTo(End) <= 0;

public bool Intersect(Interval<T> interval) => Start.CompareTo(interval.End) < 0 && interval.Start.CompareTo(End) < 0;

public override bool Equals(object? obj) => obj is Interval<T> vm && Start.Equals(vm.Start) && End.Equals(vm.End);
Expand Down

0 comments on commit 91bf01a

Please sign in to comment.