title: Mapping large set of Keys to a small set of Values
body: <p>If you had 1,000,000 keys (ints) that mapped to 10,000 values (ints).  What would be the most efficient way (lookup performance and memory usage) to implement.</p>
  
  <p>Assume the values are random.  i.e there is not a range of keys that map to a single value.</p>
  
  <p>The easiest approach I can think of is a HashMap but wonder if you can do better by grouping the keys that match a single value.</p>
  
  <pre><code>Map&lt;Integer,Integer&gt; largeMap = Maps.newHashMap();
  largeMap.put(1,4);
  largeMap.put(2,232);
  ...
  largeMap.put(1000000, 4);
  </code></pre>