|Think about Loose Coupling|
1. What (if any) storage inefficiency (relative to hashes) is created in perl when using arrays for sparsely indexed data?
It all depends on 'how sparse'":
The hash size remains static for a given number of entries, regardless of how sparse they are.
At 1 in 2, the array uses a little over half the space of the hash; but by 1 in 20, almost 3 times as much and by 1 in 50 nearly 10 times as much.
And remember, if your integer range starts at 1 billion; the array would require ~12GB (of basically wasted space), to hold the lowest value. Whilst you could wrap that over in an api to subtract 1 billion from each index, the additional subroutine call overhead would completely negate the array's lookup speed advantage; and then some.
2. What (if any) lookup inefficiency (relative to arrays) is created in perl when using hashes for positive integer indexed keys?
The array takes 0.4 seconds to do 2 million lookups of which 5% are found and 95% not.
The hash takes 1.02 seconds to do the same lookups.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In reply to Re: Array vs. Hash for sparsely integer-indexed data