in reply to Re: Re: Re: Re: print scalar %hash... erm
in thread print scalar %hash... erm
Most of the time, of course, you'll just let Perl worry about the number of buckets. Here's how that works...
When you add a new key to the hash, perl checks whether there are too many keys for the number of buckets. If that's the case, perl allocates a bunch more buckets. Then, perl goes through the whole hash, calls the hash function for each key, and figures out where it belongs in the newly-resized hash.
You're probably thinking that resizing the hash and reinserting all the elements is slow; you're absolutely right. When perl has to resize a hash, it doubles the number of buckets, which keeps it from having to resize your hashes too often.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: print scalar %hash... erm
by tye (Sage) on May 25, 2001 at 05:03 UTC | |
by larryk (Friar) on May 25, 2001 at 13:37 UTC | |
by tye (Sage) on May 26, 2001 at 00:54 UTC |