lib/HuffmanAllocator.js
function(array) {
    var firstNode = array.length - 2;
    var nextNode = array.length - 1;
    var currentDepth, availableNodes, lastNode, i;

    for (currentDepth = 1, availableNodes = 2;
         availableNodes > 0;
         currentDepth++) {
      lastNode = firstNode;
      firstNode = first (array, lastNode - 1, 0);

      for (i = availableNodes - (lastNode - firstNode); i > 0; i--) {
        array[nextNode--] = currentDepth;
      }

      availableNodes = (lastNode - firstNode) << 1;
    }
  }
function(array) {
    var firstNode = array.length - 2;
    var nextNode = array.length - 1;
    var currentDepth, availableNodes, lastNode, i;

    for (currentDepth = 1, availableNodes = 2;
         availableNodes > 0;
         currentDepth++) {
      lastNode = firstNode;
      firstNode = first (array, lastNode - 1, 0);

      for (i = availableNodes - (lastNode - firstNode); i > 0; i--) {
        array[nextNode--] = currentDepth;
      }

      availableNodes = (lastNode - firstNode) << 1;
    }
  }
function ( array ) { var firstNode = array . length - 2 ; var nextNode = array . length - 1 ; var currentDepth , availableNodes , lastNode , i ; for ( currentDepth = 1 , availableNodes = 2 ; availableNodes > 0 ; currentDepth ++ ) { lastNode = firstNode ; firstNode = first ( array , lastNode - 1 , 0 ) ; for ( i = availableNodes - ( lastNode - firstNode ) ; i > 0 ; i -- ) { array [ nextNode -- ] = currentDepth ; } availableNodes = ( lastNode - firstNode ) << 1 ; } }
A final allocation pass with no code length limit
@param array The code length array
A final allocation pass with no code length limit