Go to the previous, next section.
It should be "relatively" easy to replace the current perfect hash
function algorithm with a more exhaustive approach; the perfect hash
module is essential independent from other program modules. Additional
worthwhile improvements include:
-
Make the algorithm more robust. At present, the program halts with an
error diagnostic if it can't find a direct solution and the `-D'
option is not enabled. A more comprehensive, albeit computationally
expensive, approach would employ backtracking or enable alternative
options and retry. It's not clear how helpful this would be, in
general, since most search sets are rather small in practice.
-
Another useful extension involves modifying the program to generate
"minimal" perfect hash functions (under certain circumstances, the
current version can be rather extravagant in the generated table size).
Again, this is mostly of theoretical interest, since a sparse table
often produces faster lookups, and use of the `-S'
switch
option can minimize the data size, at the expense of slightly longer
lookups (note that the gcc compiler generally produces good code for
switch
statements, reducing the need for more complex schemes).
-
In addition to improving the algorithm, it would also be useful to
generate a C++ class or Ada package as the code output, in addition to
the current C routines.
Go to the previous, next section.