Bug 174109

Summary: hashCode() for org.eclipse.swt.graphics.Point exhibits poor collisional properties.
Product: [Eclipse Project] Platform Reporter: Josh Arnold <josharnold52>
Component: SWTAssignee: Silenio Quarti <Silenio_Quarti>
Status: NEW --- QA Contact:
Severity: minor    
Priority: P3 CC: steve_northover
Version: 3.2.1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Path for problem none

Description Josh Arnold CLA 2007-02-13 18:54:26 EST
Build ID: M20060921-0945

The current implementation of hashCode() for org.eclipse.swt.graphics.Point returns the bitwise XOR of the two coordinates.  For typical applications, this yields a small distribution of hash values relative to the universe of likely Point instances.

For example, suppose that most Point instances have coordinates in the range of -2000 to 2000.  There are approximately 16 million such points, yet there are only have 4096 possible hash values for these points.

A simple function such as:

   point.x + {large_prime_number}*point.y

would have better distributional properties.  I doubt anything more elaborate is required.

A similar observation applies to org.eclipse.swt.graphics.Rectangle as well.
Comment 1 Silenio Quarti CLA 2007-05-09 14:44:21 EDT
Created attachment 66529 [details]
Path for problem
Comment 2 Eclipse Webmaster CLA 2019-09-06 16:08:05 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.