From 91bf01aeb3bd005f1fc36af6fd3e03365c8720f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20ANDRE?= Date: Fri, 5 Jul 2024 13:09:54 +0200 Subject: [PATCH] feat: Add method contains in Interval --- src/MyNet.Utilities/Sequences/Interval.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/MyNet.Utilities/Sequences/Interval.cs b/src/MyNet.Utilities/Sequences/Interval.cs index 3bac9e3..88681b6 100644 --- a/src/MyNet.Utilities/Sequences/Interval.cs +++ b/src/MyNet.Utilities/Sequences/Interval.cs @@ -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 interval) => interval.Start.CompareTo(Start) >= 0 && interval.End.CompareTo(End) <= 0; + public bool Intersect(Interval interval) => Start.CompareTo(interval.End) < 0 && interval.Start.CompareTo(End) < 0; public override bool Equals(object? obj) => obj is Interval vm && Start.Equals(vm.Start) && End.Equals(vm.End);