Contestcen@aol.com wrote:
However, the index table offers an advantage. It can be sorted according to the alphabetic order of the strings, so the table can be searched by a binary search, or they may be arranged into a heap, which also makes for log(N) time searching.
A perfect hash table allows for constant search time.
At runtime, you cannot generally generate a perfect hash table (without overhead that is often not worth it), so O(log N) is usually ok.
But you're explicitly talking about compile-time constant strings, and in this case, you can usually make a perfact hash table. So that's your comparison.
As I wrote in PM, have you looked at programs such as gperf?
These are some of the interesting issues when dealing with a lot of compile-time constant strings, rather than squeezing out a byte or two in return for worse performance and unstable programs.
Frank