pub struct LcpDispatch { /* private fields */ }Expand description
A function-pointer dispatch for byte-level LCP. The architecture- specific pointer is selected once at construction by feature detection; later calls reduce to a register-resident indirect call.
LcpDispatch is Copy, Send, and Sync (a function pointer is
all three), so it threads freely through rayon boundaries.
The same byte-level function backs every symbol width: the
Self::lcp method casts &[S] to a byte view, calls the function
with byte-scale offsets, and divides the result by size_of::<S>()
to recover the symbol-level LCP.
Implementations§
Source§impl LcpDispatch
impl LcpDispatch
Sourcepub fn detect() -> Self
pub fn detect() -> Self
Detect the best LCP implementation for this CPU. Cheap (a couple
of is_*_feature_detected! checks) but does still touch the
feature-detection cache, so call it once per top-level build.
Sourcepub fn scalar() -> Self
pub fn scalar() -> Self
Forced scalar dispatch — useful for tests and for clients that want a deterministic baseline.
Sourcepub fn lcp<S: Symbol>(
&self,
text: &[S],
p: usize,
q: usize,
max_ctx: usize,
) -> usize
pub fn lcp<S: Symbol>( &self, text: &[S], p: usize, q: usize, max_ctx: usize, ) -> usize
Longest common prefix of text[p..] and text[q..] in symbols,
bounded by max_ctx. For any S: Symbol of non-zero size, this
dispatches to the byte-level SIMD path with byte-scaled offsets
and returns byte_lcp / size_of::<S>().
Sourcepub fn suffix_cmp<S: Symbol>(
&self,
text: &[S],
p: usize,
q: usize,
max_ctx: usize,
) -> Ordering
pub fn suffix_cmp<S: Symbol>( &self, text: &[S], p: usize, q: usize, max_ctx: usize, ) -> Ordering
Total order on two suffixes of text. Uses Self::lcp for the
shared prefix, then resolves the first differing symbol or — if
both suffixes are exhausted within max_ctx — orders by remaining
length (shorter is smaller, the convention SAIS and CaPS-SA use).
Zero-cost wrapper around Self::suffix_cmp_with for the
non-segmented case.
Sourcepub fn suffix_cmp_with<S: Symbol, L: LimitProvider>(
&self,
text: &[S],
lp: &L,
p: usize,
q: usize,
max_ctx: usize,
) -> Ordering
pub fn suffix_cmp_with<S: Symbol, L: LimitProvider>( &self, text: &[S], lp: &L, p: usize, q: usize, max_ctx: usize, ) -> Ordering
Like Self::suffix_cmp but takes a LimitProvider so the
suffix lengths used for the LCP-cap and the boundary-tie-break
come from a segmented view of the text. With PlainText
this matches Self::suffix_cmp exactly.
The boundary tie-break (when both suffixes hit their limit
before any byte differs) is delegated to
LimitProvider::boundary_order; the default
“shorter-is-smaller” gives the generalised-SA convention,
custom impls can flip it (e.g. STAR’s spacer-as-largest).
Trait Implementations§
Source§impl Clone for LcpDispatch
impl Clone for LcpDispatch
Source§fn clone(&self) -> LcpDispatch
fn clone(&self) -> LcpDispatch
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for LcpDispatch
Auto Trait Implementations§
impl Freeze for LcpDispatch
impl RefUnwindSafe for LcpDispatch
impl Send for LcpDispatch
impl Sync for LcpDispatch
impl Unpin for LcpDispatch
impl UnsafeUnpin for LcpDispatch
impl UnwindSafe for LcpDispatch
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more