diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-07-05 19:58:18 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-07-05 19:58:18 -0700 |
commit | 6e7c0080cdb160d18c0a83f5f85e92a9b988bb5f (patch) | |
tree | 10c2a569393b82bb403da79e9ad16c8ce7f7feb7 /hash.h | |
parent | 44b66777caafeebf543c32c9373632c04f748353 (diff) | |
download | txr-6e7c0080cdb160d18c0a83f5f85e92a9b988bb5f.tar.gz txr-6e7c0080cdb160d18c0a83f5f85e92a9b988bb5f.tar.bz2 txr-6e7c0080cdb160d18c0a83f5f85e92a9b988bb5f.zip |
hashing: overhaul part 2.
In this commit we feature-complete the seeded hashing
implementation. The *hash-seed* special variable is provided
from which newly created hashes take their seed. The
make-hash and hash-equal functions get an optional seed
argument. A function called gen-hash-seed is provided for
obtaining a randomized seed.
* hash.c (hash_seed): New macro.
(hash_seed_s): New symbol variable.
(make_seeded_hash): New function, made from make_hash.
(make_hash): Reduced to wrapper around make_seeded_hash.
(hash-equal): Take seed argument.
(gen_hash_seed): New function.
(hash_init): Initialize hash_seed_s and register *hash-seed*
special variable. Re-register make-hash with new optional
parameter, with regard to make_seeded_hash.
Re-register hash-equal with new optional parameter.
Register gen-hash-seed.
* hash.h (make_seeded_hash): Declared.
(hash_equal): Declaration updated.
* txr.1: Documented optional seed arguments of make-hash
and hash-equal. Documented new *hash-seed* variable
and gen-hash-seed function.
Diffstat (limited to 'hash.h')
-rw-r--r-- | hash.h | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -28,6 +28,7 @@ extern val weak_keys_k, weak_vals_k, equal_based_k, eql_based_k, userdata_k; cnum equal_hash(val obj, int *count, ucnum); +val make_seeded_hash(val weak_keys, val weak_vals, val equal_based, val seed); val make_hash(val weak_keys, val weak_vals, val equal_based); val make_similar_hash(val existing); val copy_hash(val existing); @@ -49,7 +50,7 @@ val maphash(val func, val hash); val hash_begin(val hash); val hash_next(val iter); val hash_eql(val obj); -val hash_equal(val obj); +val hash_equal(val obj, val seed); val hashv(struct args *args); val hashl(val args); val hash_construct(val hashl_args, val pairs); |