News for hackers. Stuff that matters.
Re:String.hashCode() is plenty unique by zokier on Saturday August 11, 2018 @07:07AM (#17739221)
Perfect hash functions guarantee no collisions. Of course they have other limitations, so you have to pick some tradeoffs.
Re:String.hashCode() is plenty unique by kevinwang on Saturday August 11, 2018 @09:22AM (#17739571)
I'm pretty sure, as the parent mentioned, that theoretic collisionness is impossible with |input-domaim| > |output-domain| bc of the pigeonhole principle. Especially so when input has no maximum size.
Re:String.hashCode() is plenty unique by speakeron on Saturday August 11, 2018 @09:28AM (#17739589)
However perfect it is, it can only guarantee no collisions if the size of the strings you're hashing is equal or lower than the hash size.

In this house, we obey the pigeonhole principle.

Re:String.hashCode() is plenty unique by jcranmer on Saturday August 11, 2018 @10:05AM (#17739716)
It can do better, if the input is not "every possible string." A perfect hash of the strings representing 32-bit unsigned integers can compress strings up to 10 bytes long into 4 bytes of data.
Re:String.hashCode() is plenty unique by rurban on Saturday August 11, 2018 @11:03AM (#17739909)
Sure, there is a pretty severe limitation for perfect hash functions: you have to know all the possible keys in advance. That's rarely the case.