function pqdownheap(s, tree, k)
//    deflate_state *s;
//    ct_data *tree;  /* the tree to restore */
//    int k;               /* node to move down */
{
  var v = s.heap[k];
  var j = k << 1; /* left son of k */
  while (j <= s.heap_len) {
    /* Set j to the smallest of the two sons: */
    if (j < s.heap_len &&
      smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {
      j++;
    }
    /* Exit if v is smaller than both sons */
    if (smaller(tree, v, s.heap[j], s.depth)) {
      break;
    }

    /* Exchange v with the smallest son */
    s.heap[k] = s.heap[j];
    k = j;

    /* And continue down the tree, setting j to the left son of k */
    j <<= 1;
  }
  s.heap[k] = v;
}
/* ===========================================================================
 * Restore the heap property by moving down the tree starting at node k,
 * exchanging a node with the smallest of its two sons if necessary, stopping
 * when the heap property is re-established (each father smaller than its
 * two sons).
 */
Restore the heap property by moving down the tree starting at node k,
exchanging a node with the smallest of its two sons if necessary, stopping
when the heap property is re-established (each father smaller than its
two sons).
Restore the heap property by moving down the tree starting at node k exchanging a node with the smallest of its two sons if necessary stopping when the heap property is re - established ( each father smaller than its two sons ) .
function pqdownheap(s, tree, k)
{
  var v = s.heap[k];
  var j = k << 1; 
  while (j <= s.heap_len) {
    if (j < s.heap_len &&
      smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {
      j++;
    }
    if (smaller(tree, v, s.heap[j], s.depth)) {
      break;
    }
    s.heap[k] = s.heap[j];
    k = j;
    j <<= 1;
  }
  s.heap[k] = v;
}
function pqdownheap ( s , tree , k ) { var v = s . heap [ k ] ; var j = k << 1 ; while ( j <= s . heap_len ) { if ( j < s . heap_len && smaller ( tree , s . heap [ j + 1 ] , s . heap [ j ] , s . depth ) ) { j ++ ; } if ( smaller ( tree , v , s . heap [ j ] , s . depth ) ) { break ; } s . heap [ k ] = s . heap [ j ] ; k = j ; j <<= 1 ; } s . heap [ k ] = v ; }
Restore the heap property by moving down the tree starting at node k,
 exchanging a node with the smallest of its two sons if necessary, stopping
 when the heap property is re-established (each father smaller than its
 two sons).
Restore the heap property by moving down the tree starting at node k exchanging a node with the smallest of its two sons if necessary stopping when the heap property is re - established ( each father smaller than its two sons ) .
//    deflate_state *s; //    ct_data *tree;  /* the tree to restore */ //    int k;               /* node to move down */ /* left son of k */ /* Set j to the smallest of the two sons: */ /* Exit if v is smaller than both sons */ /* Exchange v with the smallest son */ /* And continue down the tree, setting j to the left son of k */