Exemplo n.º 1
0
        /// <summary>
        /// Compare this SledProfileInfoType to another object
        /// </summary>
        /// <param name="x">First object</param>
        /// <param name="y">Second object</param>
        /// <param name="column">Column of objects</param>
        /// <param name="order">SortOrder</param>
        /// <returns>Less than zero: x is less than y. Zero: x equals y. Greater than zero: x is greater than y.</returns>
        public static int Compare(SledProfileInfoType x, SledProfileInfoType y, int column, SortOrder order)
        {
            var result = 0;

            var lstFuncs = new List <SortFunction>();

            // Add current column
            switch (column)
            {
            default: lstFuncs.Add(CompareFunctions); break;

            case 1: lstFuncs.Add(CompareNumCalls); break;

            case 2: lstFuncs.Add(CompareTotal); break;

            case 3: lstFuncs.Add(CompareAverage); break;

            case 4: lstFuncs.Add(CompareShortest); break;

            case 5: lstFuncs.Add(CompareLongest); break;

            case 6: lstFuncs.Add(CompareTotalInner); break;

            case 7: lstFuncs.Add(CompareAverageInner); break;

            case 8: lstFuncs.Add(CompareShortestInner); break;

            case 9: lstFuncs.Add(CompareLongestInner); break;
            }

            // Add others for tie breaking
            if (!lstFuncs.Contains(CompareFunctions))
            {
                lstFuncs.Add(CompareFunctions);
            }
            if (!lstFuncs.Contains(CompareNumCalls))
            {
                lstFuncs.Add(CompareNumCalls);
            }
            if (!lstFuncs.Contains(CompareTotal))
            {
                lstFuncs.Add(CompareTotal);
            }

            for (var i = 0; i < lstFuncs.Count; i++)
            {
                result = lstFuncs[i](x, y);
                if (result != 0)
                {
                    break;
                }
            }

            if (order == SortOrder.Descending)
            {
                result *= -1;
            }

            return(result);
        }
Exemplo n.º 2
0
        private static int CompareLongestInner(SledProfileInfoType pi1, SledProfileInfoType pi2)
        {
            var fl1 = pi1.TimeMaxInner;
            var fl2 = pi2.TimeMaxInner;

            if (fl1 == fl2)
            {
                return(0);
            }

            if (fl1 < fl2)
            {
                return(-1);
            }

            return(1);
        }
Exemplo n.º 3
0
        private static int CompareShortest(SledProfileInfoType pi1, SledProfileInfoType pi2)
        {
            var fl1 = pi1.TimeMin;
            var fl2 = pi2.TimeMin;

            if (fl1 == fl2)
            {
                return(0);
            }

            if (fl1 < fl2)
            {
                return(-1);
            }

            return(1);
        }
Exemplo n.º 4
0
        private static int CompareAverage(SledProfileInfoType pi1, SledProfileInfoType pi2)
        {
            var fl1 = pi1.TimeAverage;
            var fl2 = pi2.TimeAverage;

            if (fl1 == fl2)
            {
                return(0);
            }

            if (fl1 < fl2)
            {
                return(-1);
            }

            return(1);
        }
Exemplo n.º 5
0
        private static int CompareNumCalls(SledProfileInfoType pi1, SledProfileInfoType pi2)
        {
            var iNum1 = pi1.NumCalls;
            var iNum2 = pi2.NumCalls;

            if (iNum1 == iNum2)
            {
                return(0);
            }

            if (iNum1 < iNum2)
            {
                return(-1);
            }

            return(1);
        }
Exemplo n.º 6
0
 private static int CompareFunctions(SledProfileInfoType pi1, SledProfileInfoType pi2)
 {
     return(string.Compare(pi1.Function, pi2.Function, StringComparison.CurrentCulture));
 }
Exemplo n.º 7
0
        private static int CompareLongestInner(SledProfileInfoType pi1, SledProfileInfoType pi2)
        {
            var fl1 = pi1.TimeMaxInner;
            var fl2 = pi2.TimeMaxInner;

            if (fl1 == fl2)
                return 0;

            if (fl1 < fl2)
                return -1;

            return 1;
        }
Exemplo n.º 8
0
        private static int CompareShortest(SledProfileInfoType pi1, SledProfileInfoType pi2)
        {
            var fl1 = pi1.TimeMin;
            var fl2 = pi2.TimeMin;

            if (fl1 == fl2)
                return 0;

            if (fl1 < fl2)
                return -1;

            return 1;
        }
Exemplo n.º 9
0
        private static int CompareAverage(SledProfileInfoType pi1, SledProfileInfoType pi2)
        {
            var fl1 = pi1.TimeAverage;
            var fl2 = pi2.TimeAverage;

            if (fl1 == fl2)
                return 0;

            if (fl1 < fl2)
                return -1;

            return 1;
        }
Exemplo n.º 10
0
        private static int CompareNumCalls(SledProfileInfoType pi1, SledProfileInfoType pi2)
        {
            var iNum1 = pi1.NumCalls;
            var iNum2 = pi2.NumCalls;

            if (iNum1 == iNum2)
                return 0;

            if (iNum1 < iNum2)
                return -1;

            return 1;
        }
Exemplo n.º 11
0
 private static int CompareFunctions(SledProfileInfoType pi1, SledProfileInfoType pi2)
 {
     return string.Compare(pi1.Function, pi2.Function, StringComparison.CurrentCulture);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Compare this SledProfileInfoType to another object
        /// </summary>
        /// <param name="x">First object</param>
        /// <param name="y">Second object</param>
        /// <param name="column">Column of objects</param>
        /// <param name="order">SortOrder</param>
        /// <returns>Less than zero: x is less than y. Zero: x equals y. Greater than zero: x is greater than y.</returns>
        public static int Compare(SledProfileInfoType x, SledProfileInfoType y, int column, SortOrder order)
        {
            var result = 0;

            var lstFuncs = new List<SortFunction>();

            // Add current column
            switch (column)
            {
                default: lstFuncs.Add(CompareFunctions); break;
                case 1: lstFuncs.Add(CompareNumCalls); break;
                case 2: lstFuncs.Add(CompareTotal); break;
                case 3: lstFuncs.Add(CompareAverage); break;
                case 4: lstFuncs.Add(CompareShortest); break;
                case 5: lstFuncs.Add(CompareLongest); break;
                case 6: lstFuncs.Add(CompareTotalInner); break;
                case 7: lstFuncs.Add(CompareAverageInner); break;
                case 8: lstFuncs.Add(CompareShortestInner); break;
                case 9: lstFuncs.Add(CompareLongestInner); break;
            }

            // Add others for tie breaking
            if (!lstFuncs.Contains(CompareFunctions))
                lstFuncs.Add(CompareFunctions);
            if (!lstFuncs.Contains(CompareNumCalls))
                lstFuncs.Add(CompareNumCalls);
            if (!lstFuncs.Contains(CompareTotal))
                lstFuncs.Add(CompareTotal);

            for (var i = 0; i < lstFuncs.Count; i++)
            {
                result = lstFuncs[i](x, y);
                if (result != 0)
                    break;
            }

            if (order == SortOrder.Descending)
                result *= -1;

            return result;
        }