title: Is it possible to create a Minimal Perfect Hash function without a separate lookup table for a small (<64) set of keys?
body: <p>I recently read this article <a href="http://stevehanov.ca/blog/?id=119" rel="nofollow noreferrer">Throw away the keys: Easy, Minimal Perfect Hashing</a> about generating a minimal perfect hash table for a known set of keys.</p>
  
  <p>The article seems to assume that you need an intermediate table. Is there any other, simpler way to generate such a function if we assume that the set of keys is small (i.e. &lt; 64).</p>
  
  <p>In my case, I want to map a set of thread ID:s to a unique block of data within an array. The threads are started before the hash function is generated and stay constant during the running time of the program. The exact number of threads vary but stays fixed during the runtime of the program:</p>
  
  <pre><code>unsigned int thread_ids*;
  unsigned int thread_count;
  struct {
      /* Some thread specific data */
  }* ThreadData;
  
  int start_threads () {
      /* Code which starts the threads and allocates the threaddata. */
  }
  
  int f(thread_id) {
      /* return unique index into threadData */
  }
  
  int main() {
      thread_count = 64; /* This number will be small, e.g. &lt; 64 */
      start_threads();
      ThreadData[f(thread_ids[0])]
  }
  </code></pre>