As per title, this MR aims to add a Ruby implementation of the Boyer-Moore-Horspool algorithm.
This algorithm allows to search occurrences a substring in a given search string using fewer comparison with respect to the "naive" approach of performing left-to-right comparisons for every character in the search string.
Calling n the size of the search string and m the size of the substring pattern, the algorithm runs in O(nm) in the worst case, andO(n) in the average case.
In addition to the function for getting only the first match, one for getting all matches is also provided.
As per title, this MR aims to add a Ruby implementation of the Boyer-Moore-Horspool algorithm.
This algorithm allows to search occurrences a substring in a given search string using fewer comparison with respect to the "naive" approach of performing left-to-right comparisons for every character in the search string.
Calling
n
the size of the search string andm
the size of the substring pattern, the algorithm runs inO(nm)
in the worst case, andO(n)
in the average case.In addition to the function for getting only the first match, one for getting all matches is also provided.