lib/ruby/truffle/pr-zlib/lib/pr/rbzlib.rb
# Generate the codes for a given tree and bit counts (which need not be
# optimal).
# IN assertion: the array bl_count contains the bit length statistics for
# the given tree and the field len is set for all tree elements.
# OUT assertion: the field code is set for all tree elements of non
#     zero code length.
Generate the codes for a given tree and bit counts (which need not be
optimal).
IN assertion: the array bl_count contains the bit length statistics for
the given tree and the field len is set for all tree elements.
OUT assertion: the field code is set for all tree elements of non
zero code length.
Generate the codes for a given tree and bit counts ( which need not be optimal ) . IN assertion : the array bl_count contains the bit length statistics for the given tree and the field len is set for all tree elements . OUT assertion : the field code is set for all tree elements of non zero code length .
def gen_codes(tree,max_code,bl_count)
    next_code = Array.new(MAX_BITS+1,0)
    code = 0
    for bits in 1 .. MAX_BITS
      code = ((code + bl_count[bits-1]) << 1)
      next_code[bits] = code
    end
    for n in 0..max_code
      len = tree[n].dl
      next if len == 0
      tree[n].fc = bi_reverse(next_code[len], len)
      next_code[len] += 1
    end
  end
def gen_codes ( tree , max_code , bl_count ) next_code = Array . new ( MAX_BITS + 1 , 0 ) code = 0 for bits in 1 .. MAX_BITS code = ( ( code + bl_count [ bits - 1 ] ) << 1 ) next_code [ bits ] = code end for n in 0 .. max_code len = tree [ n ] . dl next if len == 0 tree [ n ] . fc = bi_reverse ( next_code [ len ] , len ) next_code [ len ] += 1 end end
Generate the codes for a given tree and bit counts (which need not be
optimal).
Generate the codes for a given tree and bit counts ( which need not be optimal ) .
tree
<not_specific>
max_code
<not_specific>
bl_count
<not_specific>