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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.