pub struct FmIndex { /* private fields */ }Expand description
An FM-index over a byte string: BWT, C array, and Occ rank table, with
the suffix array retained for locate.
Build with FmIndex::new. The index supports exact-occurrence
FmIndex::count, position FmIndex::locate, and full text recovery via
FmIndex::inverse_bwt (the BWT round-trips).
§Examples
use oxicuda_seq::string::FmIndex;
let fm = FmIndex::new(b"banana").expect("non-empty");
assert_eq!(fm.count(b"ana"), 2);
assert_eq!(fm.locate(b"ana"), vec![1, 3]);
assert_eq!(fm.count(b"xyz"), 0);
assert_eq!(fm.inverse_bwt(), b"banana");Implementations§
Source§impl FmIndex
impl FmIndex
Sourcepub fn new(s: &[u8]) -> SeqResult<Self>
pub fn new(s: &[u8]) -> SeqResult<Self>
Build the FM-index of s.
Internally appends a unique sentinel, derives the BWT from the reused
SA-IS suffix array, and precomputes the C and Occ tables.
§Errors
Returns SeqError::EmptyInput for an empty s, consistent with the
sibling string modules.
Sourcepub fn bwt_bytes(&self, sentinel_byte: u8) -> Vec<u8> ⓘ
pub fn bwt_bytes(&self, sentinel_byte: u8) -> Vec<u8> ⓘ
Borrow the BWT as raw bytes, mapping the sentinel to sentinel_byte.
The sentinel has no byte value of its own, so the caller supplies the placeholder used to render it. The placeholder is not required to be absent from the text; it is purely cosmetic for inspection/printing.
Sourcepub fn inverse_bwt(&self) -> Vec<u8> ⓘ
pub fn inverse_bwt(&self) -> Vec<u8> ⓘ
Recover the original text by inverting the BWT through the LF-mapping.
Starts at the sentinel row (row 0, since the sentinel sorts first) and
walks LF backwards, emitting characters right-to-left.