This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Scheme style auto-resizing hashtable (fwd)


Maciej Stachowiak <mstachow@mit.edu> writes:

> Iterators are very un-Schemely, IMO, Scheme is not in the business of
> telling you how to iterate.

Right.  I mostly just mentioned them for completeness, and I certainly
wouldn't want them *instead* of hash->keys or hash->alist.

> I thought a bit about this, and while hash->alist might be nice,
> hash->keys could be more memory and time efficient

I'm not sure about this.  It depends on what you're doing.  Depending
on the implementation, if you're going to use most of the keys and
values, you could potentially avoid any invocations of the hash
function if you use hash->alist, whereas with hash->keys you're going
to have to hash each key to get the value.

As I see it, hash->keys is likely to be a space (and to a lesser
extent time) win when you aren't going to need most of the values, and
hash->alist is likely to be a time (and to a lesser extent space) win
when you are.

So, if it isn't too much trouble, I can see reasons for having both.

-- 
Rob Browning <rlb@cs.utexas.edu> PGP=E80E0D04F521A094 532B97F5D64E3930