コード例 #1
0
        public static int Compare(NonComparableObject a, NonComparableObject b)
        {
            if (a == b)
            {
                return(0);
            }
            if (a == null)
            {
                return(-1);
            }
            if (b == null)
            {
                return(1);
            }
            int c;

            if ((c = a._x.CompareTo(b._x)) != 0)
            {
                return(c);
            }
            if ((c = a._y.CompareTo(b._y)) != 0)
            {
                return(c);
            }
            return(a._z.CompareTo(b._z));
        }
コード例 #2
0
        private static NonComparableObject[] MakeRandomNonComparable(int length, SortType type, Random random)
        {
            var array = new NonComparableObject[length];

            for (int i = 0; i < length; i++)
            {
                array[i] = new NonComparableObject(random);
            }
            return(ApplySortType(array, type, random, NonComparableObject.Compare));
        }