Reputation: 1173
I mapped all adjacent keys for every key on a keyboard, so that I can quickly look up a key (e.g. "a") and check if a key is adjacent or not to a in constant time.
It's hard for me to believe that this is that memory intensive, but if I only have the keys a-k it loads, but after a while, everytime I add a key, the time goes up dramatically, with all keys it doesn't load at all and is stuck on "compiling swift source files"
var adjcacencyCharacters = [
"a": Set(["a", "q", "w", "s", "z"]),
"b": Set(["b", "v", "g", "h", "n", "j", " "]),
"c": Set(["c", "x", "d", "f", "v", "g", " "]),
"d": Set(["d", "s", "e", "r", "f", "c", "x", "z"]),
"e": Set(["e", "w", "s", "d", "r"]),
"f": Set(["f", "d", "r", "t", "g", "v", "c", "x"]),
"g": Set(["g", "f", "t", "y", "h", "b", "v", "c"]),
"h": Set(["h", "g", "y", "u", "j", "v", "n", "b"]),
"i": Set(["i", "u", "j", "k", "o"]),
"j": Set(["j", "b", "u", "i", "k", "m", "n", "h"]),
"k": Set(["k", "j", "i", "o", "l", "m", "n"]),
"l": Set(["l", "k", "o", "p", "m"]),
"m": Set(["m", "j", "k", "l", "n"]),
"n": Set(["n", "b", "h", "j", "k", "m", " "]),
"o": Set(["o", "i", "k", "l", "p"]),
"p": Set(["p", "o", "l"]),
"q": Set(["q", "w", "a"]),
"r": Set(["r", "e", "d", "f", "t"]),
"s": Set(["s", "a", "w", "e", "d", "z"]),
"t": Set(["t", "r", "f", "g", "y"]),
"u": Set(["u", "y", "h", "j", "i"]),
"v": Set(["v", "c", "f", "g", "b", "h", " "]),
"w": Set(["w", "q", "a", "s", "e"]),
"x": Set(["x", "z", "s", "d", "f", "c"]),
"y": Set(["y", "t", "g", "h", "u"]),
"z": Set(["z", "a", "s", "d", "x"])
]
Upvotes: 0
Views: 50
Reputation: 93171
Look like an edge case in Swift's type inference system. You can help it by explicitly specifying the type:
var adjcacencyCharacters: [String: Set<String>] = [
...
]
Upvotes: 5