str/advanced

Advanced, low-level algorithms and helpers for power users.

This module exposes stable, well-documented building blocks intended for callers who need explicit control over search algorithms, caching of KMP maps, or want to benchmark/compare algorithms.

Types

Helper types for users building caches.

pub type KmpMaps =
  #(dict.Dict(Int, String), dict.Dict(Int, Int))

Values

pub fn build_kmp_maps(
  pattern: String,
) -> #(dict.Dict(Int, String), dict.Dict(Int, Int))

Builds KMP prefix/lookup maps for a pattern.

pub fn choose_search_strategy(
  text: String,
  pattern: String,
) -> @internal SearchStrategy

Chooses optimal search strategy using the library’s heuristics.

pub fn kmp_index_of(
  text: String,
  pattern: String,
) -> Result(Int, Nil)

KMP search (first occurrence) wrapper.

pub fn kmp_index_of_with_maps(
  text: String,
  pattern: String,
  pmap: dict.Dict(Int, String),
  pimap: dict.Dict(Int, Int),
) -> Result(Int, Nil)

KMP index of with pre-built maps.

pub fn kmp_search_all(text: String, pattern: String) -> List(Int)

Find all occurrences using the KMP algorithm.

pub fn kmp_search_all_with_maps(
  text: String,
  pmap: dict.Dict(Int, String),
  pimap: dict.Dict(Int, Int),
) -> List(Int)

KMP search with pre-built maps for better performance.

pub fn sliding_index_of(
  text: String,
  pattern: String,
) -> Result(Int, Nil)

Sliding-window search: first occurrence.

pub fn sliding_search_all(
  text: String,
  pattern: String,
) -> List(Int)

Sliding-window search: find all occurrences.

Search Document