Пример #1
0
        // Token: 0x06003A3F RID: 14911 RVA: 0x000DD100 File Offset: 0x000DB300
        private static void Heapsort(TKey[] keys, TValue[] values, int lo, int hi, IComparer <TKey> comparer)
        {
            int num = hi - lo + 1;

            for (int i = num / 2; i >= 1; i--)
            {
                ArraySortHelper <TKey, TValue> .DownHeap(keys, values, i, num, lo, comparer);
            }
            for (int j = num; j > 1; j--)
            {
                ArraySortHelper <TKey, TValue> .Swap(keys, values, lo, lo + j - 1);

                ArraySortHelper <TKey, TValue> .DownHeap(keys, values, 1, j - 1, lo, comparer);
            }
        }
Пример #2
0
        private static void Heapsort(T[] keys, int lo, int hi, IComparer <T> comparer)
        {
            int n = hi - lo + 1;

            for (int i = n / 2; i >= 1; --i)
            {
                ArraySortHelper <T> .DownHeap(keys, i, n, lo, comparer);
            }
            for (int index = n; index > 1; --index)
            {
                T[] a   = keys;
                int i   = lo;
                int num = index;
                int j   = i + num - 1;
                ArraySortHelper <T> .Swap(a, i, j);

                ArraySortHelper <T> .DownHeap(keys, 1, index - 1, lo, comparer);
            }
        }
Пример #3
0
        private static void Heapsort(TKey[] keys, TValue[] values, int lo, int hi, IComparer <TKey> comparer)
        {
            int n = hi - lo + 1;

            for (int i = n / 2; i >= 1; --i)
            {
                ArraySortHelper <TKey, TValue> .DownHeap(keys, values, i, n, lo, comparer);
            }
            for (int index = n; index > 1; --index)
            {
                TKey[]   keys1   = keys;
                TValue[] values1 = values;
                int      i       = lo;
                int      num     = index;
                int      j       = i + num - 1;
                ArraySortHelper <TKey, TValue> .Swap(keys1, values1, i, j);

                ArraySortHelper <TKey, TValue> .DownHeap(keys, values, 1, index - 1, lo, comparer);
            }
        }