code wiki / (root) / nx_boyer_moore.nx

nx_boyer_moore.nx

buildroot/runtime/nx_boyer_moore.nx

2912 B81 linesdepth 2pulls 2 transitivereach 2 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_boyer_moore.nx -- Boyer-Moore string search (bad-character heuristic). Find the first occurrence of `pattern` in `text`, returning the starting byte index or -1. Uses the bad-character rule (a.k.a. Horspool-simplified BM): preprocess pattern into a 256-entry skip table, then scan text right-to-left within each alignment; on mismatch jump ahead by the table. genealogy_id: boyer_moore_1977_cacm lineage_id: single_pattern_exact_string_search references: Boyer & Moore "A Fast String Searching Algorithm", CACM 20(10):762-772, October 1977. license: public_domain (1977 academic publication) complexity: best O(n/m), avg O(n+m), worst O(n*m) (this BM-bad-char variant; full Galil/Apostolico-Giancarlo gives O(n+m)).

dependencies 2 imports · 2 importers

nx_syscalls.nx nx_tier.nx nx_boyer_moore.nx nx_boyer_moore_test.nx nx_triangulation_sort_string_graph

imports: nx_syscalls.nxnx_tier.nx

imported by: nx_boyer_moore_test.nxnx_triangulation_sort_string_graph.nx

structs

none

consts

26const NX_BM_BAD_TABLE_LEN: nx_size = 256

functions

30func nx_boyer_moore_build_table(pattern: *u8, m: nx_size, table: *nx_idx) -> nx_int