From 5cc4256a931b98ea167291397421d0db60c5d40c Mon Sep 17 00:00:00 2001 From: pacien Date: Sun, 2 Dec 2018 00:22:56 +0100 Subject: implement lzss block --- src/huffman/huffmantree.nim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/huffman/huffmantree.nim') diff --git a/src/huffman/huffmantree.nim b/src/huffman/huffmantree.nim index 58a840e..f3fce1b 100644 --- a/src/huffman/huffmantree.nim +++ b/src/huffman/huffmantree.nim @@ -31,6 +31,11 @@ type HuffmanTreeNode*[T: SomeUnsignedInt] = ref object of leaf: value*: T +proc maxValue*[T](node: HuffmanTreeNode[T]): T = + case node.kind: + of branch: node.maxChildValue + of leaf: node.value + proc huffmanBranch*[T](left, right: HuffmanTreeNode[T]): HuffmanTreeNode[T] = HuffmanTreeNode[T]( kind: branch, left: left, right: right, @@ -45,11 +50,6 @@ proc `==`*[T](a, b: HuffmanTreeNode[T]): bool = of branch: a.left == b.left and a.right == b.right of leaf: a.value == b.value -proc maxValue*[T](node: HuffmanTreeNode[T]): T = - case node.kind: - of branch: node.maxChildValue - of leaf: node.value - proc deserialise*[T](bitReader: BitReader, valueType: typedesc[T]): HuffmanTreeNode[T] = let valueBitLength = bitReader.readBits(valueLengthFieldBitLength, uint8).int proc readNode(): HuffmanTreeNode[T] = -- cgit v1.2.3