Last active
April 28, 2020 14:06
-
-
Save 7foots/3b4ca9efb46d989acbb84f953b8cc206 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
extension Dictionary where Key == Int64, Value == SKNode { | |
func int64key(_ key: (Int32, Int32)) -> Int64 { | |
return (Int64(key.0) << 32) | Int64(key.1) | |
} | |
subscript(_ key: (Int32, Int32)) -> SKNode? { | |
get { | |
return self[int64key(key)] | |
} | |
set(newValue) { | |
self[int64key(key)] = newValue | |
} | |
} | |
} | |
// Usage example | |
var dictionary: [Int64 : SKNode] = [:] | |
dictionary[(0,1)] = SKNode() | |
dictionary[(1,0)] = SKNode() | |
print(dictionary) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment