Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Efficient selection mechanism?

by salva (Canon)
on Jan 14, 2014 at 14:41 UTC ( [id://1070564]=note: print w/replies, xml ) Need Help??


in reply to Efficient selection mechanism?

Supposing the number of distinct small numbers is really going to stay small and the number of entries on the array on the thousands:
# untested! my %bitmap; for my $ix (0..$#AoA) { for my $sn (@{$AoA[$ix]}) { vec($bitmap{$sn}, $ix, 1) = 1; } } my @nope = (2, 13, 3, 16); my $bad = '' for my $bit (@nope) { $bad ||= $bitmap{$bit}; } my @ok = grep { !vec($bad, $_, 1) } 0..$#AoA
That should use no more than a few KB and be O(N).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-20 05:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found