Skip to content

Instantly share code, notes, and snippets.

@chriswebb09
Created May 14, 2017 22:33
Show Gist options
  • Save chriswebb09/06044f72ee7b72dfc1b4a0a47419c974 to your computer and use it in GitHub Desktop.
Save chriswebb09/06044f72ee7b72dfc1b4a0a47419c974 to your computer and use it in GitHub Desktop.
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