General Interests & Hobbies > Java Programming

Hashcode of 2d point

<<< (2/3) >>>

imthenull:

--- Quote from: Pure_ on October 10, 2014, 01:51:16 PM ---I took the liberty of going through every point (I tested until 600x600 with success - any higher would be intractable with my method of testing). Anyways, x << 16 | y seems to work, not sure if it's what you're looking for.

edit: You can reduce the shifts of course.

--- End quote ---
IMO this would be ideal, seeing as you're literally packing two 16 bit integers into 32 bits. You wouldn't ever have the same hash unless two points were the same

Davidi2:
that's what most RSPS use to hash location points I believe

Pure_:

--- Quote from: Davidi2 on October 11, 2014, 01:14:56 AM ---that's what most RSPS use to hash location points I believe

--- End quote ---
Not sure, but it should work fine unless if she has some different requirement from the hash code.

RuneAgent:

--- Quote from: Pure_ on October 11, 2014, 05:59:21 AM ---
--- Quote from: Davidi2 on October 11, 2014, 01:14:56 AM ---that's what most RSPS use to hash location points I believe

--- End quote ---
Not sure, but it should work fine unless if she has some different requirement from the hash code.

--- End quote ---

yes actually Runescape does use that method. Also yes it worked fine thanks

Zymus:
The maximum size of any square that could be generate, and have that calculation provide 0 hash collisions, is 46340x46340. If the point is outside of those bounds, it is guaranteed to collide with at lease one other point within the 46340x46340 area.

So as long as you keep it under that, you should have no collisions.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version
Powered by SMFPacks SEO Pro Mod |