This commit is contained in:
parent
6f95e3d9b7
commit
568df00fdc
|
@ -26,11 +26,6 @@ const
|
|||
0xDF, 0x3F, 0xBF, 0x7F, 0xFF
|
||||
]
|
||||
|
||||
type
|
||||
Coin = object
|
||||
symbols: seq[uint16]
|
||||
weight: uint64
|
||||
|
||||
# {.push checks: off.}
|
||||
|
||||
template failCompress() =
|
||||
|
@ -38,7 +33,16 @@ template failCompress() =
|
|||
ZippyError, "Unexpected error while compressing"
|
||||
)
|
||||
|
||||
func quickSort(s: var seq[Coin], lo, hi: int) =
|
||||
func huffmanCodeLengths(
|
||||
frequencies: seq[uint64], minCodes, maxBitLen: int
|
||||
): (int, seq[uint8], seq[uint16]) =
|
||||
# See https://en.wikipedia.org/wiki/Huffman_coding#Length-limited_Huffman_coding
|
||||
|
||||
type Coin = object
|
||||
symbols: seq[uint16]
|
||||
weight: uint64
|
||||
|
||||
func quickSort(s: var seq[Coin], lo, hi: int) =
|
||||
if lo >= hi:
|
||||
return
|
||||
|
||||
|
@ -55,11 +59,6 @@ func quickSort(s: var seq[Coin], lo, hi: int) =
|
|||
quickSort(s, lo, pivot - 1)
|
||||
quickSort(s, pivot + 1, hi)
|
||||
|
||||
func huffmanCodeLengths(
|
||||
frequencies: seq[uint64], minCodes, maxBitLen: int
|
||||
): (int, seq[uint8], seq[uint16]) =
|
||||
# See https://en.wikipedia.org/wiki/Huffman_coding#Length-limited_Huffman_coding
|
||||
|
||||
var numSymbolsUsed: int
|
||||
for freq in frequencies:
|
||||
if freq > 0:
|
||||
|
|
Loading…
Reference in New Issue