Created
July 11, 2015 11:38
-
-
Save invokr/3239da0f530f2c1f0ff6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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