title: Whats the best way of storing a stream of data of unknown range and distribution in a hash table which provides O(1) access?
body: <p>Lets say we had a <em>stream of data</em> comming into us (of unknown range and distribution) and we wanted to <strong>store the last X</strong> number of values in a hash table which provides <strong>O(1)</strong> access, how would we do this?</p>
  
  <p>For simplicity lets say the data is a <em>stream of numbers</em> of <em>unknown range and distribution</em>.
  In order to <strong>map</strong> these numbers to an <em>element of an array</em> we would need a <strong>hash function</strong> that takes account of the <em>data range and distribution</em>.</p>
  
  <p><li>I guess we'd either estimate this range upfront or maintain some statistics on the data coming in and adjust the hash function accordingly.
  <li>Also we'd need a way of rejigging the array one the X threshold is met.</p>
  
  <p>Any thoughts or ideas for doing this as fast as possible?</p>