Given a structure Personthat has string properties nameand surname, I would like to write a hashing algorithm that is efficient and avoids conflicts for people with removable names and surnames (e.g. Lara Ray and Ray Lara.).
I already know to distract from string concatenation in Swift, so ideally I think about XORusing two variables and shifting bits one of them to solve a plug-in problem. Is there something wrong with this?
struct Person {
let name: String
let surname: String
var hashValue: Int {
return surname.hashValue << 1 ^ name.hashValue
}
}
source
share