Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Array vs. Hash for sparsely integer-indexed data (bit vectors)

by BrowserUk (Pope)
on Jan 25, 2013 at 19:21 UTC ( #1015393=note: print w/ replies, xml ) Need Help??


in reply to Re: Array vs. Hash for sparsely integer-indexed data
in thread Array vs. Hash for sparsely integer-indexed data

Also worth considering: if your lookups are (or lend themselves to be adapted to) a simple boolean truth; vec can reduce the space requirement to a fraction of that used by either arrays or hashes and yields lookup time that also beat arrays:

$vec = ''; vec( $vec, $_*20, 1) =1 for 1 .. 1e5;; print total_size \$vec;; 250056 $found = 0; say time; vec( $vec, $_, 1 ) and ++$found for 1 .. 20e5; s +ay time; say $found;; 1359141761.02608 1359141761.35157 100000

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.


Comment on Re^2: Array vs. Hash for sparsely integer-indexed data (bit vectors)
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2015-07-08 00:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls