in reply to Re^4: Locating a specified number of contiguous 0 bits within a large bitstring efficiently.
in thread Locating a specified number of contiguous 0 bits within a large bitstring efficiently.
withmy $p = join '|', map { "$pre[$_]\\0{@{[($N-$_)>>3]}}$suf[($N-$_)&0x7] +" } 0..7;
By construction, only one will match and $#- will tell you which one. We place the leftparen so that the group always starts at the first byte that's beginning with a zero bit. Then you just have to subtract the number of zero bits at the end of the byte that $pre[$_] is matching, but that's just $#- - 1. So the answer ismy $p = join '|', map { "$pre[$_](\\0{@{[($N-$_)>>3]}}$suf[($N-$_)&0x7 +])" } 0..7;
Still needs a bit more work to handle the $N < 8 case.$-[$#-]*8 - $#- + 1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Locating a specified number of contiguous 0 bits within a large bitstring efficiently.
by BrowserUk (Patriarch) on Jun 07, 2013 at 20:23 UTC | |
by wrog (Friar) on Jun 08, 2013 at 02:52 UTC | |
by BrowserUk (Patriarch) on Jun 08, 2013 at 06:20 UTC | |
by wrog (Friar) on Jun 08, 2013 at 11:37 UTC |