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)



jglascoe@jay.giss.nasa.gov writes:
> WARNING!  My next post will be 600 lines of C code: "hashtab-type.c"
> 
> Feel free to delete it if you're not into looking at other peoples' C code
> (and, if you're REALLY not into C code, flame me for it ;) 
> 
> I'm posting the code now in hopes that others will give me some feedback
> on it.  IMHO the code is sleek and clean, I'm happy with it.
> 
> If there are no objections, I plan to start writing wrappers for, e.g.
> "hashtab-setq!", "hashtab-delv!", etc.

It's probably more useful to specify the equality predicate and hasher
when creating the hash table as others have mentioned, otherwise your
precomputed hash values will be worthless.

> I'll also throw in some
> utitilities, "hashtab-for-each" and "hashtab-map" ("hashtab->keys" and
> friends would then be a simple application of "hashtab-map").
> 
> I don't plan on writing an iterator, i.e. a zero-argument procedure
> yielding key-value pairs on each successive call, since such a procedure
> depends on the state of the hash table remaining fixed.  Resizing hash
> tables just refuse to stay fixed.

If you have hashtable-foreach you could write one using call/cc anyway.

 - Maciej