summaryrefslogtreecommitdiffstats
path: root/hash.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-10-11 07:44:28 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-10-11 07:44:28 -0700
commit2838fb0ab11336c46bb3ed43a147c1cdf843630d (patch)
tree835b6590e4008bb38cee5a3ed22c56ed2d54fcf4 /hash.h
parent52fed6047b4e12e50912e2561f224889cc2d035d (diff)
downloadtxr-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.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/hash.h b/hash.h
index 82d07528..da30adab 100644
--- a/hash.h
+++ b/hash.h
@@ -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);