Source File
huffman.go
Belonging Package
compress/bzip2
package bzip2
import
nodes []huffmanNode
nextNode int
}
type huffmanNode struct {
left, right uint16
leftValue, rightValue uint16
}
const invalidNodeValue = 0xffff
, := .leftValue, .rightValue
if == 1 {
=
} else {
=
}
return
}
}
}
if len() < 2 {
panic("newHuffmanTree: too few symbols")
}
var huffmanTree
+= 1 << (32 - )
}
type huffmanSymbolLengthPair struct {
value uint16
length uint8
}
func ( *huffmanTree, []huffmanCode, uint32) ( uint16, error) {
:= uint32(1) << (31 - )
if len() < 2 {
return 0, StructuralError("empty Huffman tree")
}
.right = invalidNodeValue
.rightValue = [0].value
} else {
.right, = (, , +1)
}
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |