예제 #1
0
            private static int Compare(SccStamp lhs, SccStamp rhs)
            {
                Debug.Assert(lhs != null);
                Debug.Assert(rhs != null);

                return lhs.Revision.CompareTo(rhs.Revision);
            }
예제 #2
0
 /// <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);
 }
예제 #3
0
        /// <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);
        }
예제 #4
0
        /// <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];
        }