Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Array vs. Hash (newbie perlguts)by Ryszard (Priest) |
on Aug 31, 2001 at 02:20 UTC ( [id://109223]=note: print w/replies, xml ) | Need Help?? |
I'm thinking the solution relies on the sparcity. if all your array elements are populated, (ie your data is dense) i think the economies of scale in fine tuning your model will outweigh any benifits you will get in memory saving.
if you know all the indicies before hand i wouldnt go for a hash of arrays as why complicate things? $array[0] is easier to read than $hash{1}[0] i'm guessing by saying you've got 1..m dimensions in your data (represented by the hash element), why not split it out into 3 or 4 arrays, and only populate the array if there is a value to populate it. this way you can make your data denser while conserving space not really required by a hash. of course this makes it more difficult to parse the data around as you have to parse four structures (or references to), rather than a single reference. Without more specifics of the project and data model, its a little too difficult to make any specific suggestions. As always it looks like a trade off.. this time around its resources againts complexity.
In Section
Seekers of Perl Wisdom
|
|