1 Feb 01:05
Re: ltable.c table deletion
Josh Haberman <jhaberman <at> gmail.com>
2012-02-01 00:05:19 GMT
2012-02-01 00:05:19 GMT
On Jan 31, 2012 at 2:06 PM, Doug Currie wrote:
> On Jan 31, 2012, at 3:01 PM, Josh Haberman wrote:
> > […] it occurred to me that Brent's
> > variation (evicting a colliding element that is not in its main
> > position) prevents chain coalescing
>-
> No, it doesn't. Imagine a full hash table with all keys in their main
> position (perfectly hashed). All chains are coalesced.
Like Lua, I am using chained scatter (what you call "explicit
chaining" below), so in the scenario you describe every entry's "next"
pointer will be NULL and no chains will be coalesced.
> > […] I was surprised that Lua didn't
> > implement it.
>
> Note that Lua uses explicit chaining (with next fields in the TKey),
> so chains never coalesce at the expense of one link pointer per hash
> bucket.
Chains don't coalesce in Lua *only because* Lua uses Brent's variation.
With naive chained scatter they can coalesce, as described in my
original link, or to use an even simpler example, insert 1 into this
table (assume the identity hash for integers):
val next
+---+----+
0 | 0 | 1 |--+
+---+----+ |
1 | 4 | |<-+
(Continue reading)
RSS Feed