1234567891011121314151617181920212223242526272829303132 |
- public int hashCode() {
- int hash = 0;
- int skip = Math.max(1, length() / 8);
- for (int i = 0; i < length(); i += skip)
- hash = (hash * 37) + charAt(i);
- return hash;
- }
- public int hashCode() {
- int hash = 0;
- for (int i = 0; i < length(); i++)
- hash = (hash * 31) + charAt(i);
- return hash;
- }
- strlst@ayaya ~ echo -n abcdefghijklmnopqrstuvwx | wc -c
- 24
- strlst@ayaya ~ echo -n a11d11g11j11m11p11s11v11 | wc -c
- 24
- strlst@ayaya ~ calc 24 / 8
- 3.00000000000000000000
- kollision:
- 012 012 012 012 012 012 012 012
- abc def ghi jkl mno pqr stu vwx
- a11 d11 g11 j11 m11 p11 s11 v11
- prim zahlen haben bei beiden varianten denselben effekt
- I) durchläufe d: 1 <= d <= length() / 8
- II) durchläufe d: 1 <= d <= length()
|