| 10933 | * two sons). |
| 10934 | */ |
| 10935 | function pqdownheap(s, tree, k) |
| 10936 | // deflate_state *s; |
| 10937 | // ct_data *tree; /* the tree to restore */ |
| 10938 | // int k; /* node to move down */ |
| 10939 | { |
| 10940 | var v = s.heap[k]; |
| 10941 | var j = k << 1; /* left son of k */ |
| 10942 | while (j <= s.heap_len) { |
| 10943 | /* Set j to the smallest of the two sons: */ |
| 10944 | if (j < s.heap_len && |
| 10945 | smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) { |
| 10946 | j++; |
| 10947 | } |
| 10948 | /* Exit if v is smaller than both sons */ |
| 10949 | if (smaller(tree, v, s.heap[j], s.depth)) { break; } |
| 10950 | |
| 10951 | /* Exchange v with the smallest son */ |
| 10952 | s.heap[k] = s.heap[j]; |
| 10953 | k = j; |
| 10954 | |
| 10955 | /* And continue down the tree, setting j to the left son of k */ |
| 10956 | j <<= 1; |
| 10957 | } |
| 10958 | s.heap[k] = v; |
| 10959 | } |
| 10960 | |
| 10961 | |
| 10962 | // inlined manually |