On May 24, 2005, at 3:05 AM, Paul Elschot wrote:
>> + public int hashCode() {
>> + int result;
>> + result = clauses.hashCode();
>> + result = 29 * result + slop;
>>
>
> How about:
> result += slop * 29;
>
>
>> + result = 29 * result + (inOrder ? 1 : 0);
>>
>
> result += (inOrder ? 1 : 0); // or some other constants larger
> than 1
>
>
>> + result = 29 * result + field.hashCode();
>>
>
> result ^= field.hashCode(); // bitwise exclusive or
>
>
>> + return result;
>> + }
>> }
>>
>
> ?
> The idea is to preserve and use as many of the earlier bits
> as possible. Multiplying by a large number by 29 can loose 4-5
> of the original high bits.
Ok, those adjustments are fine. I let IDEA generate the .hashCode
method in this case and left it at that - but I'll modify it with
your suggestions.
Thanks,
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
|