Skip to content

Instantly share code, notes, and snippets.

@invokr
Created July 11, 2015 11:38
Show Gist options
  • Save invokr/3239da0f530f2c1f0ff6 to your computer and use it in GitHub Desktop.
Save invokr/3239da0f530f2c1f0ff6 to your computer and use it in GitHub Desktop.
// Node is either HuffmanLeaf or HuffmanNode
// Leaf = only value
// Node = left and right, both are either a leaf or a node
node := (*fp.tree).(HuffmanNode)
for fp.finished == false {
if r.readBits(1) == 1 {
switch i := node.right.(type) {
case HuffmanLeaf:
i.value.(FieldPathOpFcn)(r, fp)
break
case HuffmanNode:
node = i
break
}
} else {
switch i := node.left.(type) {
case HuffmanLeaf:
i.value.(FieldPathOpFcn)(r, fp)
break
case HuffmanNode:
node = i
break
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment