title: Perfect hash function for strings known in advance
body: <p>I have 4000 strings and I want to create a perfect hash table with these strings. The strings are known in advance, so my first idea was to use a series of <code>if</code> statements:</p>
  
  <pre><code> if (name=="aaa")
        return 1;
   else if (name=="bbb")
        return 2;
          .
          .
          .
   // 4000th `if' statement
  </code></pre>
  
  <p>However, this would be very inefficient. Is there a better way?</p>