Skip to content

Instantly share code, notes, and snippets.

@leodabus
Last active January 28, 2017 00:07
Show Gist options
  • Save leodabus/e6c4c9e0676c28badd64a702a20113c5 to your computer and use it in GitHub Desktop.
Save leodabus/e6c4c9e0676c28badd64a702a20113c5 to your computer and use it in GitHub Desktop.
struct Point: Hashable {
let cgPoint: CGPoint
var nsValue: NSValue { return cgPoint as NSValue }
var x: CGFloat { return cgPoint.x }
var y: CGFloat { return cgPoint.y }
init(x: CGFloat, y: CGFloat) {
self.cgPoint = CGPoint(x: x, y: y)
}
init(cgPoint: CGPoint = .zero) {
self.cgPoint = cgPoint
}
static func == (lhs: Point, rhs: Point) -> Bool {
return lhs.cgPoint == rhs.cgPoint
}
public var hashValue: Int {
return nsValue.hashValue
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment