Contrequarte.SmartPlug.Core.TimePeriod.IsIntersectionFree C# (CSharp) Méthode

IsIntersectionFree() public static méthode

Checking, if an enumeration of TimePeriod objects doesn't contain intersecting TimePeriods
public static IsIntersectionFree ( IEnumerable timePeriods ) : bool
timePeriods IEnumerable enumeration of Timeperiod objects to check
Résultat bool
        public static bool IsIntersectionFree(IEnumerable<TimePeriod> timePeriods)
        {

            TimePeriod[] testPeriods = timePeriods.OrderBy(tp => tp.Begin.Hour * 100 + tp.Begin.Minute).ToArray();
            for (int i = 0; i < testPeriods.Length - 1; i++)
            {
                if (PointInTime.Compare(testPeriods[i].End, testPeriods[i + 1].Begin) != -1)
                {
                    return false;
                }
            }
            return true;
        }