|Perl: the Markov chain saw|
Re: fastest way to compare two arraysby BrowserUk (Pope)
|on Apr 14, 2011 at 00:47 UTC||Need Help??|
This shoudl be a little quicker. It uses a bit vector rather than a hash which is a bit quicker to start. It then scans the bit vector 64-bits at a time until it finds a possibility and then by bit until it isolates the next value:
Worst case of only 65535 being available, it does 242+63 tests+incs, rather than 15500.
If I were writing this in assembler, I'd test lo/hi 32-bit; lo/hi 16-bit; lo/hi 8-bit before hitting the bits individually thereby reducing the 63 tests/incs to 10.
It require 8k of string which is quite possibly smaller than your hash. That coudl be reduced further by not storing bits for 0 .. 50_000.
It's a POC. I haven't tested the edge cases.
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.