A Java library for byte pattern matching and searching
Knuth-Morris-Pratt string-searching algorithm: DFA-less version
news.ycombinator.com | 2021-01-22
That was a fun read, I liked the use of cmbc to validate the algorithm.
For those who are interested, there's a good tool to specifically test string matching algorithms here:
There are so many string matching algorithms now, with different best and worst cases. Some work better on low alphabets (eg DNA), so are better for text or high entropy data, some take advantage of CPU instructions, some are generic. The real challenge is picking the right algorithm.
I've implemented a few of them in java here, and extended them to support multi byte matching at any position:
Made a search algorithm, send help.
reddit.com/r/learnprogramming | 2021-01-13
At the moment the numbers for average and worst case show the time increasing from ~4 miliseconds to ~8 as the query increases size from 8 characters to 4000+ over these texts. In the best case it matches or exceeds all other algorithms I've tested it against.
smart-tool/smart is an open source project licensed under GNU General Public License v3.0 or later which is an OSI approved license.