summaryrefslogtreecommitdiff
path: root/lib/Tie/SubstrHash.pm
diff options
context:
space:
mode:
authorRandy J Ray <rjray@uswest.com>1996-02-06 10:04:47 -0700
committerAndy Dougherty <doughera@lafcol.lafayette.edu>1996-02-06 10:04:47 -0700
commit64d0c9732b520ac8f3a9448f7c3f9f5b4209bd6d (patch)
treeb9565a30f3b8e16afcf8ff1fc652b1b674a0d6c1 /lib/Tie/SubstrHash.pm
parent6c31b3367b143518785862fbdca365a32245ff3d (diff)
downloadperl-64d0c9732b520ac8f3a9448f7c3f9f5b4209bd6d.tar.gz
Documentation patch: Tie::Hash, Tie::Scalar, Tie::SubstrHash
[This finishes a job started by Randy Ray with perl5.002b1f.] This patch updates the files lib/TieHash.pm and lib/SubstrHash.pm. Those two files are moved to a new directory called lib/Tie. A new tie-related class for scalars, lib/Tie/Scalar.pm, is added. Each of these has pod documentation that passes through pod2man without complaint. All package names are updated to reflect this structure, and the "standard" sub-classes for hashes and scalars are named Tie::StdHash and Tie::StdScalar, in keeping with the group consensus. With this, the documentation for Tie::Hash should be fine, Tie::Scalar exists and is documented, and Tie::SubstrHash (formerly just SubstrHash) is also documented, albeit weakly. I have no examples of usage to show, and I suspect a possible bug or two, but without examples it's hard to say. As it happens, this patch also impacts the DBM-style extensions, as they (DB_File, NDBM_File, GBM_File, ODBM_File, SDBM_File) all inherited from the old TieHash.pm as a base class.
Diffstat (limited to 'lib/Tie/SubstrHash.pm')
-rw-r--r--lib/Tie/SubstrHash.pm38
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/Tie/SubstrHash.pm b/lib/Tie/SubstrHash.pm
index 6250e73848..a01c66ef8d 100644
--- a/lib/Tie/SubstrHash.pm
+++ b/lib/Tie/SubstrHash.pm
@@ -1,4 +1,40 @@
-package SubstrHash;
+package Tie::SubstrHash;
+
+=head1 NAME
+
+Tie::SubstrHash - Fixed-table-size, fixed-key-length hashing
+
+=head1 SYNOPSIS
+
+ require Tie::SubstrHash;
+
+ tie %myhash, Tie::SubstrHash, $key_len, $value_len, $table_size;
+
+=head1 DESCRIPTION
+
+The B<Tie::SubstrHash> package provides a hash-table-like interface to
+an array of determinate size, with constant key size and record size.
+
+Upon tying a new hash to this package, the developer must specify the
+size of the keys that will be used, the size of the value fields that the
+keys will index, and the size of the overall table (in terms of key-value
+pairs, not size in hard memory). I<These values will not change for the
+duration of the tied hash>. The newly-allocated hash table may now have
+data stored and retrieved. Efforts to store more than C<$table_size>
+elements will result in a fatal error, as will efforts to store a value
+not exactly C<$value_len> characters in length, or reference through a
+key not exactly C<$key_len> characters in length. While these constraints
+may seem excessive, the result is a hash table using much less internal
+memory than an equivalent freely-allocated hash table.
+
+=head1 CAVEATS
+
+Because the current implementation uses the table and key sizes for the
+hashing algorithm, there is no means by which to dynamically change the
+value of any of the initialization parameters.
+
+=cut
+
use Carp;
sub TIEHASH {