Bug 174109 - hashCode() for org.eclipse.swt.graphics.Point exhibits poor collisional properties.
Summary: hashCode() for org.eclipse.swt.graphics.Point exhibits poor collisional prope...
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.2.1   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-13 18:54 EST by Josh Arnold CLA
Modified: 2019-09-06 16:08 EDT (History)
1 user (show)

See Also:


Attachments
Path for problem (1.68 KB, patch)
2007-05-09 14:44 EDT, Silenio Quarti CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.