in reply to Re: What is the most efficient way to see if a hash is empty?
in thread What is the most efficient way to see if a hash is empty?
From perldata: "If you evaluate a hash in scalar context, it returns false if the hash is empty. If there are any key/value pairs, it returns true; more precisely, the value returned is a string consisting of the number of used buckets and the number of allocated buckets, separated by a slash."..
Am I right to assume that if the hash is non-empty if (%hash) and scalar(%hash) are simply returning a stored number of buckets (no loops to count buckets)? If so, that would be exactly want I wanted - O(1). I missed that paragraph. Thanks.
Best, beth
Update: just to be clear - this is meant to be an internals question, not a "trust the docs" question. perlguts doesn't go that deep into the internals of hash implementation.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: What is the most efficient way to see if a hash is empty?
by moritz (Cardinal) on Apr 28, 2009 at 08:35 UTC | |
|
Re^3: What is the most efficient way to see if a hash is empty?
by Anonymous Monk on Apr 28, 2009 at 09:31 UTC | |
by ELISHEVA (Prior) on Apr 28, 2009 at 09:53 UTC | |
by moritz (Cardinal) on Apr 28, 2009 at 11:06 UTC | |
by ELISHEVA (Prior) on Apr 28, 2009 at 11:21 UTC | |
by BrowserUk (Patriarch) on Apr 28, 2009 at 12:23 UTC | |
by Anonymous Monk on Apr 28, 2009 at 10:13 UTC | |
|
Re^3: What is the most efficient way to see if a hash is empty?
by Anonymous Monk on Apr 28, 2009 at 08:25 UTC |