function zip_pqdownheap()

in themes/docsy/static/js/deflate.js [953:977]


    function zip_pqdownheap(
        tree,	// the tree to restore
        k) {	// node to move down
        var v = zip_heap[k];
        var j = k << 1;	// left son of k

        while (j <= zip_heap_len) {
            // Set j to the smallest of the two sons:
            if (j < zip_heap_len &&
                zip_SMALLER(tree, zip_heap[j + 1], zip_heap[j]))
                j++;

            // Exit if v is smaller than both sons
            if (zip_SMALLER(tree, v, zip_heap[j]))
                break;

            // Exchange v with the smallest son
            zip_heap[k] = zip_heap[j];
            k = j;

            // And continue down the tree, setting j to the left son of k
            j <<= 1;
        }
        zip_heap[k] = v;
    }