Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Efficient selection mechanism?

by ikegami (Pope)
on Jan 14, 2014 at 17:13 UTC ( #1070577=note: print w/replies, xml ) Need Help??

in reply to Efficient selection mechanism?

Not indexed, but a regex should search an 8k string pretty fast.
my $AoA = pack 'C*', map @$_, @AoA; my $omit = $AoA[0]; my $pat = '[^'.( join '', map quotemeta, pack 'C*', @$omit ).']{4}'; my $re = qr/\G(?:.{4})*?($pat)/s; my @matches = map [ unpack 'C*', $_ ], $AoA =~ /$re/g;

The following avoids recreating the original arrays at the expense of two bytes per element of @AoA.

my $AoA = pack '(C4S)*', map { @{ $AoA[$_] }, $_ } 0..$#AoA; my $omit = $AoA[0]; my $pat = '[^'.( join '', map quotemeta, pack 'C*', @$omit ).']{4}'; my $re = qr/\G(?:.{6})*?$pat(..)/s; my @matches = @AoA[ map unpack 'S', $AoA =~ /$re/g ];

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1070577]
[shmem]: moritz: that sound somewhat reconciling to me
[shmem]: indeed these 3 points are the ones I'm missing most in my daily work
vrk adds oatmeal cookies to the platter on the sideboard.

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2017-04-27 14:53 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (508 votes). Check out past polls.