|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
flattening Complex Datastructuresby Ctrl-z (Friar) |
| on Feb 10, 2003 at 18:06 UTC ( #234186=perlmeditation: print w/ replies, xml ) | Need Help?? |
|
I love hashes!. But even more than I love hashes, I love Hashes of Hashes. This meditation is somewhat related to A
memory efficient hash, trading off speed - does it already exist?. In fact, on re-reading that node before posting this, I see aristotle briefly touched on this topic - so i guess im on old ground here.
While recursively dumping my own large HoH out to screen, something occured to me - something Im not sure is rediculous or totally obvious.
Hashes consist of key/value pairs. So, (yup, you guessed it!) instead of filling hashref values with more hashrefs, how about simply creating a new key in the original hash, with the unique path that would have been in the HoH. So this
becomes...
Dot syntax at no extra cost ;) (i) specific Lookups, Inserts and Deletes should be as fast as any hash (?). ..and some sober practicalities... (i) I seem to recall reading that hashes can overflow?
Can anyone expand on the circumstances where this approach might either pay
off or fail completely? Any opinions are appreciated
Back to
Meditations
|
|
||||||||||||||||||||||||||||||||||||