implementing hashCode() for compound integer keys
<p>I have a class which has three integers to represent it: a serverID, a streamID and an messageID.</p>

<p>I have some <code>HashSet</code> that are small but I do lots of stuff like set intersection on, and others that have 10K+ elements in.</p>

<p>There are only a handful of values for serverID, but they are truly random numbers with a full 32-bits of randomness.  Often there is only one serverID for a whole hashtable; other times just a couple of serverIDs.</p>

<p>The streamID is a small number, typically 0 but may be 1 or 2 sometimes.</p>

<p>The messageID is sequentially increasing for each serverID/streamID pair.</p>

<p>I currently have:</p>

<pre><code>(-messageID &lt;&lt; 24) ^ messageID ^ serverID ^ streamID
</code></pre>

<p>I want to understand that I have a good hash function despite having a sequentially increasing messageID and not a lot of other bits to mix in.</p>

<p>What makes a good <code>hashCode</code> and how can I best mix these three numbers?</p>
