diff --git a/Sources/DecodingHuffmanTree.swift b/Sources/DecodingHuffmanTree.swift index 5f60040e..97040412 100644 --- a/Sources/DecodingHuffmanTree.swift +++ b/Sources/DecodingHuffmanTree.swift @@ -12,16 +12,16 @@ class DecodingHuffmanTree { private var tree: [Int] private let leafCount: Int - init(bootstrap: [[Int]], _ bitReader: BitReader) { + init(bootstrap: [(symbol: Int, codeLength: Int)], _ bitReader: BitReader) { self.bitReader = bitReader - // Fills the 'lengths' array with numerous HuffmanLengths from a 'bootstrap'. + // Fills the 'lengths' array with pairs of (symbol, codeLength) from a 'bootstrap'. var lengths: [[Int]] = [] - var start = bootstrap[0][0] - var bits = bootstrap[0][1] + var start = bootstrap[0].symbol + var bits = bootstrap[0].codeLength for pair in bootstrap[1.. 0 { for i in start.. Int { diff --git a/Sources/EncodingHuffmanTree.swift b/Sources/EncodingHuffmanTree.swift index 0bbfb19a..a85a1789 100644 --- a/Sources/EncodingHuffmanTree.swift +++ b/Sources/EncodingHuffmanTree.swift @@ -12,16 +12,16 @@ class EncodingHuffmanTree { private var codingIndices: [[Int]] - init(bootstrap: [[Int]], throw symbolNotFoundError: Error, _ bitWriter: BitWriter) { + init(bootstrap: [(symbol: Int, codeLength: Int)], throw symbolNotFoundError: Error, _ bitWriter: BitWriter) { self.bitWriter = bitWriter self.symbolNotFoundError = symbolNotFoundError - // Fills the 'lengths' array with numerous HuffmanLengths from a 'bootstrap'. + // Fills the 'lengths' array with pairs of (symbol, codeLength) from a 'bootstrap'. var lengths: [[Int]] = [] - var start = bootstrap[0][0] - var bits = bootstrap[0][1] + var start = bootstrap[0].symbol + var bits = bootstrap[0].codeLength for pair in bootstrap[1.. 0 { for i in start..