Am 04.03.2010 23:38, schrieb Marek Kozieł:
2010/3/4 Ulf Zibis:
5.
Intern string do not need hash codes co comparing cos they have same
address, so first loop would return true if they are equal, after this
we need only to check if they are not equal:
if (isIntern()&&anotherStr
2010/3/4 Ulf Zibis :
>> 5.
>> Intern string do not need hash codes co comparing cos they have same
>> address, so first loop would return true if they are equal, after this
>> we need only to check if they are not equal:
>>
>>>
>>> if (isIntern()&& anotherString.isIntern()) return false;
>>>
>
>
Much thanks for your effort.
Am 04.03.2010 21:31, schrieb Marek Kozieł:
@Ulf
Few explanations:
1.
Intersting alternative, but I'm afraid, this is against the spec.
Shifting all 0's to 1 would break String's hash definition: h = 31 * h +
val[i++].
Yes it does, any way i think spec i
@Ulf
Few explanations:
1.
> Intersting alternative, but I'm afraid, this is against the spec.
> Shifting all 0's to 1 would break String's hash definition: h = 31 * h +
> val[i++].
Yes it does, any way i think spec is to tight here. Do we really need
hash of each value even if String have length
Am 04.03.2010 19:33, schrieb Marek Kozieł:
Hello,
I would suggest:
public int hashCode() {
int h = hash;
if (h == 0) {
h = 0;
char[] val = value;
for (int i = offset, limit = count + i; i != limit; )
h = 31 * h + val[i++];