mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
30 lines
658 B
Swift
30 lines
658 B
Swift
// Copyright (c) 2017 Timofey Solomko
|
|
// Licensed under MIT License
|
|
//
|
|
// See LICENSE for license information
|
|
|
|
import Foundation
|
|
|
|
struct HuffmanLength {
|
|
|
|
let symbol: Int
|
|
let codeLength: Int
|
|
|
|
}
|
|
|
|
extension HuffmanLength: Comparable {
|
|
|
|
static func <(left: HuffmanLength, right: HuffmanLength) -> Bool {
|
|
if left.codeLength == right.codeLength {
|
|
return left.symbol < right.symbol
|
|
} else {
|
|
return left.codeLength < right.codeLength
|
|
}
|
|
}
|
|
|
|
static func ==(left: HuffmanLength, right: HuffmanLength) -> Bool {
|
|
return left.codeLength == right.codeLength && left.symbol == right.symbol
|
|
}
|
|
|
|
}
|