private static int Compare(SccStamp lhs, SccStamp rhs) { Debug.Assert(lhs != null); Debug.Assert(rhs != null); return lhs.Revision.CompareTo(rhs.Revision); }
/// <summary> /// Sorts an array of <see cref="SccStamp"/> objects by their /// revision numbers in ascending order. /// </summary> public static void SortByRevision(SccStamp[] stamps) { SortByRevision(stamps, false); }
/// <summary> /// Sorts an array of <see cref="SccStamp"/> objects by their /// revision numbers in ascending or descending order. /// </summary> public static void SortByRevision(SccStamp[] stamps, bool descending) { IComparer comparer = new RevisionComparer(); if (descending) comparer = new ReverseComparer(comparer); Array.Sort(stamps, comparer); }
/// <summary> /// Finds the latest stamp among an array of <see cref="SccStamp"/> /// objects. The latest stamp is the one with the highest revision /// number. /// </summary> public static SccStamp FindLatest(SccStamp[] stamps) { if (stamps == null) throw new ArgumentNullException("stamps"); if (stamps.Length == 0) return null; stamps = (SccStamp[]) stamps.Clone(); SortByRevision(stamps, /* descending */ true); return stamps[0]; }