1N/ATie::SubstrHash - Fixed-table-size, fixed-key-length hashing 1N/A require Tie::SubstrHash; 1N/A tie %myhash, 'Tie::SubstrHash', $key_len, $value_len, $table_size; 1N/AThe B<Tie::SubstrHash> package provides a hash-table-like interface to 1N/Aan array of determinate size, with constant key size and record size. 1N/AUpon tying a new hash to this package, the developer must specify the 1N/Asize of the keys that will be used, the size of the value fields that the 1N/Akeys will index, and the size of the overall table (in terms of key-value 1N/Apairs, not size in hard memory). I<These values will not change for the 1N/Aduration of the tied hash>. The newly-allocated hash table may now have 1N/Adata stored and retrieved. Efforts to store more than C<$table_size> 1N/Aelements will result in a fatal error, as will efforts to store a value 1N/Anot exactly C<$value_len> characters in length, or reference through a 1N/Akey not exactly C<$key_len> characters in length. While these constraints 1N/Amay seem excessive, the result is a hash table using much less internal 1N/Amemory than an equivalent freely-allocated hash table. 1N/ABecause the current implementation uses the table and key sizes for the 1N/Ahashing algorithm, there is no means by which to dynamically change the 1N/Avalue of any of the initialization parameters. 1N/AThe hash does not support exists(). 1N/A croak(
"Table is full ($tsize->[0] elements)")
if $$
self[
5] > $
tsize->[
0];
1N/A croak "Tie::SubstrHash does not support exists()";
1N/A# using POSIX::ceil() would be too heavy, and not all platforms have it. 1N/Asub findgteprime {
# find the smallest prime integer greater than or equal to