Re: How best to implement a hash table in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg125123] Re: How best to implement a hash table in Mathematica
- From: Joseph Gwinn <joegwinn at comcast.net>
- Date: Wed, 22 Feb 2012 05:33:57 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jho21j$5sb$1@smc.vnet.net> <jhqmsq$fbt$1@smc.vnet.net> <jhstus$nku$1@smc.vnet.net> <jhvu5c$80d$1@smc.vnet.net>
In article <jhvu5c$80d$1 at smc.vnet.net>,
Richard Fateman <fateman at cs.berkeley.edu> wrote:
> On 2/19/2012 11:49 PM, Joseph Gwinn wrote:
> > In article<jhqmsq$fbt$1 at smc.vnet.net>,
> > Richard Fateman<fateman at cs.berkeley.edu> wrote:
>
> >> Initializing a hashtable with 10^4 (identical?) empty keys makes no
> >> sense. Did I misunderstand your message?
> >
> > No, you understood correctly. Please see my response to David Bailey
> > for the rationale.
> >
> > Joe Gwinn
> >
> Again, I may misunderstand, but I think you can accomplish the same
> thing by typing
>
> f[x_]:= {}
>
> if {} is the default empty value.
This creates the hashtable, and gives it a name. In a hashtable, it is
not the table that's empty, it's this or that specific cell that's
empty, in an unpredictable and changing pattern. So one would be
attempting to update and access f[x], where x is a random integer. So,
I just tried this, and it works just fine, including handling variable
lists.
So, this and related approaches may be workable. I will have to
implement them in a real application, and check performance and
scalability.
Joe Gwinn