Hacker News new | ask | show | jobs
by ErikCorry 1270 days ago
Not sure what you mean by this. Hashes have collisions, so how would that work?

The attraction of the CoordSet is that it behaves as if it is storing actual objects, but is actually saving memory. So the abstraction hides the optimization, which makes it easier to reason about the rest of the program.

1 comments

Collisions are extremely unlikely. You will know if a collision occurred if the answer is rejected. If that happens you can tweak the hash algorithm and try again. This would allow saving coordinates outside of the [-1000, 30000] range.

I think it would be easier to reason about because,

1. KISS: You don't need to verify the encoding code is correct.

2. YAGNI: The program doesn't require reading the coordinates back out, so the program should not store the coordinates in a format that can do that.