Skip to content

Instantly share code, notes, and snippets.

@dennda
Created November 7, 2014 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennda/821864c529b1f10020b4 to your computer and use it in GitHub Desktop.
Save dennda/821864c529b1f10020b4 to your computer and use it in GitHub Desktop.
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