MZSanford has asked for the wisdom of the Perl Monks concerning the following question:
Because of the nature, this hash of hashes can be of any depth, with any number of keys at each level (seems there are a lot of mid-mgmt people). I have a recursive hash-walking algorithm i am using to find two variables ,$high_keys and $high_depth (2 and 4 respectivly in this case). But, given the maximum number of keys, and the maximum depth, the best i can do is calculate how the max-plausable height like this :$hash{'mgr'}{ 'mid-mgmt' => { coderA => {}, coderB => { 'regexp monkey' => {}, }, }, }; ## for quick ref : # /mgr # /mgr/mid-mgmt # /mgr/mid-mgmt/coderA # /mgr/mid-mgmt/coderB # /mgr/mid-mgmt/coderB/regexp monkey
The problem with this is that it always calculates the height as if each level had the maximum number of keys.## all of the object stuff is gone, this is alg only # $height_of_a_box = font_height + all padding $height = ($height_of_a_box * ($high_keys*$high_depth));
+-------+ | mgmt | +-------+ | +----------+ +----| mid-mgmt | +----------+ | +--------+ |----| coderA | | +--------+ | +--------+ +----| coderB | +--------+ | +--------+ +---| monkey | +--------+
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hashes of doom !
by suaveant (Parson) on Sep 06, 2001 at 18:24 UTC | |
by MZSanford (Curate) on Sep 06, 2001 at 18:29 UTC | |
|
Re (tilly) 1: hashes of doom !
by tilly (Archbishop) on Sep 06, 2001 at 18:35 UTC | |
by MZSanford (Curate) on Sep 06, 2001 at 21:09 UTC | |
by tilly (Archbishop) on Sep 06, 2001 at 21:48 UTC | |
by tye (Sage) on Sep 07, 2001 at 00:50 UTC | |
by tilly (Archbishop) on Sep 07, 2001 at 01:40 UTC |