Re: [xml] xmlHashCreate and xmlHashAddEntry - hashs of unknown size?



On Fri, Feb 02, 2007 at 09:54:51AM -0600, David Hagood wrote:
Suppose I have a hash table who's size I do not know at compile time - it
might end up with one entry or a thousand.

What value should I pass to xmlHashCreate for the size?

If I pass a value "N", and at run time try to add "N+1" items to the hash,
will it error or will it just increase the hash size?

  Don't worry, go for the lower unless you know it will be huge.
The algorithm automatically adjusts the hash table size when it detects
the clash list is growing too long in an entry. The reajustment takes a
bit of computation though, which you can avoid if you know it will grow a
lot by giving a large initial value.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]