The main problem with getting a volatile hash function is that you cannot provide equality transitivity. Usually equality is considered transitive. That is, A = B and B = C means that A = C (which also implies that A, B and C will have the same hash code). However, with your definition of equality, you could have A = B, B = C, and A! = C. In the ideal case, unequal elements would have different hash codes, so A and C would have different hash codes; but they cannot, because both are equal to B, so they must have the same hash code.
The only way to get a volatile hash function is to find out about your shared collection. You will need to split the collection into “equality boxes”, where each element in the bin will be equal to some other element in the box (including the possibility of having one bin). After you have done this separation, you can use it to generate a volatile algorithm (provided that you get more than one bean) to generate a hash code.
The fact of the matter is that the idea of equality cells is that there can be many such hopper configurations. As a selection criterion, you can increase the number of mailboxes (to improve the performance of the search in the hash table). The degenerative case (as indicated by Reed Copsie's correct answer) is that you put everything in the same box (although, as the supercards indicate in the comments below, the name "equality boxes" then becomes misleading). This does not violate any hash value restrictions, but it will lead to poor performance in algorithms that expect to have value for creating a non-degenerate split.
As supercards show, in order to satisfy hash value restrictions, the following should be true: if two elements are in two different cells, they should not be equal (however, two elements in the same box should not be equal).
Ethan brown
source share