Ejemplo n.º 1
0
        public void RestoreHeapDown(short[] tree, int k)
        {
            int n = this.heap[k];

            for (int index = k << 1; index <= this.heapLen; index <<= 1)
            {
                if (index < this.heapLen && Deflater.IsSmaller(tree, this.heap[index + 1], this.heap[index], this.depth))
                {
                    ++index;
                }
                if (!Deflater.IsSmaller(tree, n, this.heap[index], this.depth))
                {
                    this.heap[k] = this.heap[index];
                    k            = index;
                }
                else
                {
                    break;
                }
            }
            this.heap[k] = n;
        }