diff --git a/Sources/Common/CodeLength.swift b/Sources/Common/CodeLength.swift index bea23541..788886ad 100644 --- a/Sources/Common/CodeLength.swift +++ b/Sources/Common/CodeLength.swift @@ -10,6 +10,25 @@ struct CodeLength: Equatable { let symbol: Int let codeLength: Int + static func lengths(from bootstrap: [(symbol: Int, codeLength: Int)]) -> [CodeLength] { + // Fills the 'lengths' array with pairs of (symbol, codeLength) from a 'bootstrap'. + var lengths = [CodeLength]() + var start = bootstrap[0].symbol + var bits = bootstrap[0].codeLength + for pair in bootstrap[1.. 0 { + for i in start.. [CodeLength] { - // Fills the 'lengths' array with pairs of (symbol, codeLength) from a 'bootstrap'. - var lengths = [CodeLength]() - var start = bootstrap[0].symbol - var bits = bootstrap[0].codeLength - for pair in bootstrap[1.. 0 { - for i in start.. [CodeLength] { var lengths = [CodeLength]()