MCPcopy Create free account
hub / github.com/TruthHun/BookStack / pqdownheap

Function pqdownheap

static/word2md/mammoth.browser.js:22917–22941  ·  view source on GitHub ↗
(s, tree, k)

Source from the content-addressed store, hash-verified

22915 * two sons).
22916 */
22917function pqdownheap(s, tree, k)
22918// deflate_state *s;
22919// ct_data *tree; /* the tree to restore */
22920// int k; /* node to move down */
22921{
22922 var v = s.heap[k];
22923 var j = k << 1; /* left son of k */
22924 while (j <= s.heap_len) {
22925 /* Set j to the smallest of the two sons: */
22926 if (j < s.heap_len &&
22927 smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {
22928 j++;
22929 }
22930 /* Exit if v is smaller than both sons */
22931 if (smaller(tree, v, s.heap[j], s.depth)) { break; }
22932
22933 /* Exchange v with the smallest son */
22934 s.heap[k] = s.heap[j];
22935 k = j;
22936
22937 /* And continue down the tree, setting j to the left son of k */
22938 j <<= 1;
22939 }
22940 s.heap[k] = v;
22941}
22942
22943
22944// inlined manually

Callers 1

build_treeFunction · 0.70

Calls 1

smallerFunction · 0.70

Tested by

no test coverage detected