[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Make-Hash-Table



    Date: Tue, 22 Jan 1985  22:56 EST
    From: Skef Wholey <Wholey@CMU-CS-C.ARPA>

    I propose the following clarification to the specification of how the
    :rehash-threshold and :rehash-size options interact:

    There are four cases:

	    1. :rehash-threshold is an integer and :rehash-size is an integer.

	    In this case, when a hash table is grown (by adding rehash-size to
	    the current hash table size), the rehash-threshold is scaled up by
	    multiplying it by the ceiling of the ratio of the new size to the
	    original size.

	    2. :rehash-threshold is an integer and :rehash-size is a float.

	    In this case, when a hash table is grown (by multiplying the current
	    hash table size by the rehash-size), the rehash-threshold is scaled
	    up by multiply it, too, by the rehash-size.

Don't forget to convert the result of that multiplication from a float back
to an integer!

	    3. :rehash-threshold is a float and :rehash-size is an integer.

	    In this case, when a hash table is grown (by adding rehash-size to
	    the current hash table size), we just leave the rehash-threshold
	    alone.

	    4. :rehash-threshold is a float and :rehash-size is a float.

	    To grow, just multiply the current hash table size by the rehash-size
	    and again leave the rehash-threshold alone.

    If :rehash-threshold is a fixnum, then the hash table is grown when the number
    of entries in the table exceeds the :rehash-threshold.  If :rehash-threshold is
    a float, then the hash table is grown when the ratio of the number of entries
    in the to the size of the table exceeds the :rehash-threshold.

I think you can eliminate cases 1 and 2 by the trick of doing
  (when (integerp rehash-threshold)
    (setq rehash-threshold (/ (float rehash-threshold) size)))
at initialization.  Now it scales automatically.

    This seems to be the "obvious" interpretation of the description on pages
    283-284, and this is how I intended to implement hash tables for Spice Lisp.

I believe this interpretation.

Bug-CLCP: We don't seem to implement any case other than #4.  This is mentioned
in the release notes.