Created
May 14, 2017 22:33
-
-
Save chriswebb09/06044f72ee7b72dfc1b4a0a47419c974 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
struct HashTable<Key: Hashable, Value> { | |
// Hash table setup | |
func index(for key: Key) -> Int { | |
var divisor: Int = 0 | |
for key in String(describing: key).unicodeScalars { | |
divisor += abs(Int(key.value.hashValue)) | |
} | |
return abs(divisor) % buckets.count | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment