Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Storing simple Value Pairs

by Marshall (Prior)
on Oct 19, 2011 at 18:54 UTC ( #932470=note: print w/ replies, xml ) Need Help??


in reply to Storing simple Value Pairs

What's the best way to store/organize them in perl?

That depends upon how you want to access the data. Looks to me like you pretty much understand the options. The 2-D AoA is a logical choice if you just need a sequential list of coordinates.

The AoH is also commonly done (your option 1). "Wasteful" or not is a subjective thing. For something simple this can take less storage than you might think. This is similar to a C array of struct.

In your option (2), use HoA (hash of array) instead of a simple hash if you want to represent more than one point with the same X value. I would make all of the hash entries pointers to array (not do some as simple values if only one) just to make things more "regular" and eliminate special case.


Comment on Re: Storing simple Value Pairs

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://932470]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2014-09-20 19:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (160 votes), past polls