in reply to Working with BIG binary fields
if you need a really fast way, you might create an array with 256 entries, in which every possible entry aka byte points to an array of the set bits in it:
my @SetBits= ( [], [0], [1], [0,1], [2], [0,2], [1,2], [3], [0,3] ... ... sub findsetbits { #feed with array of bytes my @result; my $offset=0; foreach my $byte (@_) { foreach (@{$SetBits[$byte]}) { push @result, $_+$offset; } $offset+= 8; } return @result; }
(Untested)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Working with BIG binary fields
by AnomalousMonk (Archbishop) on Sep 21, 2010 at 00:28 UTC |