unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: HJSTEIN@bloomberg.net (Harvey J. Stein)
Cc: Greg Troxel <gdt@ir.bbn.com>
Subject: Re: Resizing hash tables in Guile
Date: 13 Feb 2003 13:30:58 -0500	[thread overview]
Message-ID: <kiwu1f8jan1.fsf@blinky.bloomberg.com> (raw)
In-Reply-To: Joris van der Hoeven's message of "Thu, 13 Feb 2003 15:24:32 +0100 (MET)"

Joris van der Hoeven <TeXmacs@math.u-psud.fr> writes:

 > >  > average.  This means that, on average, operations are O(1).
 > > 
 > > Inserts are, but lookups aren't necessarily.
 > 
 > Both aren't necessarily, because inserting requires looking up too.

Yes, if you want to return an error for inserting 2 items with the
same key.  No, if you allow multiple items with the same key.

 > > And good hashing functions are still hard to write.
 > 
 > I do not really agree. A good hash algorithm for lists (or strings),
 > which I use in TeXmacs, is ...

I guess "hard" isn't quite the word for it.  What I meant was that the
obvious ones don't work well.  You basically need to look up a good
one to get good behavior.  Tcl's fcn works pretty well too.  I forget
what it does.

 > > With this many items, log(N) is still just 32, so an O(log(N))
 > > algorithm will still beat an O(1) algorithm if it's really
 > > log_2(N) vs 32.
 > 
 > Yes, but the O(1) is really *table lookup* multiplied by a small
 > constant here, so this is *fast*. You may adjust the small constant
 > by choosing an appropriate threshold for "size/nr buckets".

Not just table lookup.  Also hash calculation from the key, which can
be more time consuming than a key comparison, and key comparisons for
everything in the bucket.

 > > Trees also sort the data for you, which hash tables don't give you.
 > 
 > But you need a compairison operation for that,
 > which may be even less natural than a hash function.

Yes.  For hash tables you just need a key equality test.  For trees
you need to be able to order the keys.

 > > So, ideally, one would have a hash table object with & without
 > > resizing, and various sorts of tree (AVL, red/black, B*, etc) objects.
 > > insert and delete and map would be methods that work on all of the
 > > above, with map on trees returning the data in sorted order.  For that
 > > matter, insert & delete might as well also work on lists...
 > 
 > Agreed: ideally, we have everything :^)

I think we're on the same page here...

STk had a nice scheme interface for hash tables.  The code uses the
Tcl hash tables, they autoresize and if I recall correctly, many of
the important parameters can be modified.  You might want to model the
guile stuff on this, or utilize this work.  I advocated this when the
discussion came up years ago on the guile mailing list.

BTW, there was a long discussion of hash tables on the guile list some
number of years ago.  At the time I didn't like liked the guile (aka
scm) hash tables.  They were a very minimal implementation.  The user
had to do too much to use them.  I don't know what it's like these
days, but it'd certainly be nice to have a good implementation
available which includes autosizing.

-- 
Harvey Stein
Bloomberg LP
hjstein@bloomberg.com


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


  reply	other threads:[~2003-02-13 18:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <Pine.GSO.3.96.1030208160743.22945E-100000@anh>
     [not found] ` <87lm0o7951.fsf@alice.rotty.yi.org>
     [not found]   ` <rmiu1fcnrhj.fsf@fnord.ir.bbn.com>
     [not found]     ` <1044889242.1033.310.camel@localhost>
     [not found]       ` <xy77kc8krhr.fsf@nada.kth.se>
     [not found]         ` <xy74r7ckqmy.fsf@nada.kth.se>
2003-02-11 13:59           ` Resizing hash tables in Guile Mikael Djurfeldt
2003-02-11 17:34             ` Roland Orre
     [not found]               ` <ljy94lhgkb.fsf@burns.dt.e-technik.uni-dortmund.de>
2003-02-12 17:47                 ` Mikael Djurfeldt
2003-02-12 20:44                   ` Rob Browning
2003-02-12 16:10             ` Marius Vollmer
2003-02-12 17:53               ` Mikael Djurfeldt
2003-02-12 20:17                 ` Roland Orre
2003-02-13  9:35                   ` Mikael Djurfeldt
2003-02-13 13:55                     ` Harvey J. Stein
2003-02-13 14:24                       ` Joris van der Hoeven
2003-02-13 18:30                         ` Harvey J. Stein [this message]
2003-02-13 20:02                           ` Paul Jarc
2003-02-13  9:52                   ` Joris van der Hoeven
2003-02-12 20:55             ` Rob Browning
2003-02-13 10:43               ` Mikael Djurfeldt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=kiwu1f8jan1.fsf@blinky.bloomberg.com \
    --to=hjstein@bloomberg.net \
    --cc=gdt@ir.bbn.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).