public static int OnSort(SpeedInterval left, SpeedInterval right) { int result = left.mWorld.CompareTo(right.mWorld); if (result != 0) return result; // These are intentionally inversed (larger numbers to the top) result = right.mDays.Count.CompareTo(left.mDays.Count); if (result != 0) return result; DaysOfTheWeek leftDay = DaysOfTheWeek.None; foreach (DaysOfTheWeek day in left.mDays) { if (leftDay < day) { leftDay = day; } } DaysOfTheWeek rightDay = DaysOfTheWeek.None; foreach (DaysOfTheWeek day in right.mDays) { if (rightDay < day) { rightDay = day; } } result = leftDay.CompareTo(rightDay); if (result != 0) return result; result = left.mStartHour.CompareTo(right.mStartHour); if (result != 0) return result; return 0; }
public void Add(SpeedInterval interval) { mIntervals.Add(interval); mIntervals.Sort(new Comparison <SpeedInterval>(SpeedInterval.OnSort)); ResetSpeeds(); }
public static int OnSort(SpeedInterval left, SpeedInterval right) { int result = left.mWorld.CompareTo(right.mWorld); if (result != 0) { return(result); } // These are intentionally inversed (larger numbers to the top) result = right.mDays.Count.CompareTo(left.mDays.Count); if (result != 0) { return(result); } DaysOfTheWeek leftDay = DaysOfTheWeek.None; foreach (DaysOfTheWeek day in left.mDays) { if (leftDay < day) { leftDay = day; } } DaysOfTheWeek rightDay = DaysOfTheWeek.None; foreach (DaysOfTheWeek day in right.mDays) { if (rightDay < day) { rightDay = day; } } result = leftDay.CompareTo(rightDay); if (result != 0) { return(result); } result = left.mStartHour.CompareTo(right.mStartHour); if (result != 0) { return(result); } return(0); }
public void Remove(SpeedInterval interval) { mIntervals.Remove(interval); ResetSpeeds(); }
public void Add(SpeedInterval interval) { mIntervals.Add(interval); mIntervals.Sort(new Comparison<SpeedInterval>(SpeedInterval.OnSort)); ResetSpeeds(); }