Created
November 7, 2014 18:28
-
-
Save dennda/821864c529b1f10020b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PDFViewBitmapCacheKey: Hashable { | |
let name: String | |
let width: Int | |
let height: Int | |
let scaleMode: PDFImage.ScaleMode | |
let page: PDFImage.Page | |
init(name: String, size: CGSize, scaleMode: PDFImage.ScaleMode, page: PDFImage.Page) { | |
self.name = name | |
// Note that we want to make sure we're using integer values for the size, or we might fall prey to float imprecisions | |
self.width = Int(size.width) | |
self.height = Int(size.height) | |
self.scaleMode = scaleMode | |
self.page = page | |
} | |
var hashValue: Int { | |
return name.hashValue | | |
width.hashValue << (sizeof(Int) * 1) | | |
height.hashValue << (sizeof(Int) * 2) | | |
scaleMode.hashValue << (sizeof(Int) * 3) | | |
page.hashValue << (sizeof(Int) * 4) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment