diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-10-11 07:44:28 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-10-11 07:44:28 -0700 |
commit | 2838fb0ab11336c46bb3ed43a147c1cdf843630d (patch) | |
tree | 835b6590e4008bb38cee5a3ed22c56ed2d54fcf4 /hash.h | |
parent | 52fed6047b4e12e50912e2561f224889cc2d035d (diff) | |
download | txr-2838fb0ab11336c46bb3ed43a147c1cdf843630d.tar.gz txr-2838fb0ab11336c46bb3ed43a147c1cdf843630d.tar.bz2 txr-2838fb0ab11336c46bb3ed43a147c1cdf843630d.zip |
hash: implement :eq-based.
We need eq based hash tables to fix a problem in *print-circle*.
* hash.c (enum hash_type, hash_type_t): New enum type.
(eq_based_k): New keyword variable.
(eq_hash, eq_hash_op): New static functions.
(hash_print_op): Ensure we print eq-based hashes with the
correct keyword.
(hash_assq, hash_aconsq_new_c): New static functions.
(hash_eq_ops): New static structure.
(do_make_hash): New function, made from previous contents of
make_seeded_hash.
(make_seeded_hash): Wrapper around do_make_hash now.
(make_eq_hash): New function.
(hashv): Parse out :eq-based argument. Use make_eq_hash if it
is present.
(hash_init): Initialize eq_based_k.
* hash.h (eq_based_k, make_eq_hash): Declared.
Diffstat (limited to 'hash.h')
-rw-r--r-- | hash.h | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -25,11 +25,13 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -extern val weak_keys_k, weak_vals_k, equal_based_k, eql_based_k, userdata_k; +extern val weak_keys_k, weak_vals_k, userdata_k; +extern val equal_based_k, eql_based_k, eq_based_k; ucnum 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_eq_hash(val weak_keys, val weak_vals); val make_similar_hash(val existing); val copy_hash(val existing); val gethash_c(val self, val hash, val key, loc new_p); |