pub struct Bwt { /* private fields */ }Expand description
Burrows-Wheeler Transform of a byte string.
Constructed by appending a sentinel $ to the input, building the suffix
array, and reading off the last column of the sorted rotation matrix.
Implementations§
Source§impl Bwt
impl Bwt
Sourcepub fn build(text: &[u8]) -> Self
pub fn build(text: &[u8]) -> Self
Build the BWT of text.
A sentinel $ (0x00) is appended internally and is lexicographically
smaller than every input byte.
§Example
use cyanea_seq::bwt::Bwt;
let bwt = Bwt::build(b"banana");
assert_eq!(bwt.len(), 7); // 6 + sentinelSourcepub fn primary_index(&self) -> usize
pub fn primary_index(&self) -> usize
Position of the sentinel character ($) in the BWT.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the BWT is empty (only possible for empty input + sentinel).
Sourcepub fn invert(&self) -> Vec<u8> ⓘ
pub fn invert(&self) -> Vec<u8> ⓘ
Reconstruct the original text (without sentinel) from the BWT.
Uses the LF-mapping: build C table (cumulative counts of characters smaller than c) and occurrence counts, then walk from the row containing the sentinel to reconstruct the text in reverse.
§Example
use cyanea_seq::bwt::Bwt;
let text = b"banana";
let bwt = Bwt::build(text);
let recovered = bwt.invert();
assert_eq!(recovered, text);Trait Implementations§
Auto Trait Implementations§
impl Freeze for Bwt
impl RefUnwindSafe for Bwt
impl Send for Bwt
impl Sync for Bwt
impl Unpin for Bwt
impl UnsafeUnpin for Bwt
impl UnwindSafe for Bwt
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
Mutably borrows from an owned value. Read more