/// Construct a new instance of the wavelet matrix of given text of length n (DNA alphabet plus sentinel symbol).
/// Complexity: O(n).
Construct a new instance of the wavelet matrix of given text of length n (DNA alphabet plus sentinel symbol).
Construct a new instance of the wavelet matrix of given text of length n ( DNA alphabet plus sentinel symbol ) .
pub fn new(text: &[u8]) -> Self {
        let width = text.len();
        let height: usize = 3; // hardcoded for alphabet size <= 8 (ACGTN$)
        let mut curr_zeros: Vec<u8> = text.to_vec();
        let mut curr_ones: Vec<u8> = Vec::new();
        let mut zeros: Vec<u64> = Vec::new();
        let mut levels: Vec<RankSelect> = Vec::new();
        for level in 0..height {
            let mut next_zeros: Vec<u8> = Vec::with_capacity(width);
            let mut next_ones: Vec<u8> = Vec::with_capacity(width);
            let mut curr_bits: BitVec<u8> = BitVec::new_fill(false, width as u64);
            let shift = (height - level - 1) as u8;
            build_partlevel(
                &curr_zeros,
                shift,
                &mut next_zeros,
                &mut next_ones,
                &mut curr_bits,
                0,
            );
            build_partlevel(
                &curr_ones,
                shift,
                &mut next_zeros,
                &mut next_ones,
                &mut curr_bits,
                curr_zeros.len() as u64,
            );
            curr_zeros = next_zeros;
            curr_ones = next_ones;
            let level = RankSelect::new(curr_bits, 1);
            levels.push(level);
            zeros.push(curr_zeros.len() as u64);
        }
        WaveletMatrix {
            width,
            height,
            zeros,
            levels,
        }
    }
pub fn new ( text : & [ u8 ] ) -> Self { let width = text . len ( ) ; let height : usize = 3 ; // hardcoded for alphabet size <= 8 (ACGTN$) let mut curr_zeros : Vec < u8 > = text . to_vec ( ) ; let mut curr_ones : Vec < u8 > = Vec :: new ( ) ; let mut zeros : Vec < u64 > = Vec :: new ( ) ; let mut levels : Vec < RankSelect > = Vec :: new ( ) ; for level in 0 .. height { let mut next_zeros : Vec < u8 > = Vec :: with_capacity ( width ) ; let mut next_ones : Vec < u8 > = Vec :: with_capacity ( width ) ; let mut curr_bits : BitVec < u8 > = BitVec :: new_fill ( false , width as u64 ) ; let shift = ( height - level - 1 ) as u8 ; build_partlevel ( & curr_zeros , shift , & mut next_zeros , & mut next_ones , & mut curr_bits , 0 , ) ; build_partlevel ( & curr_ones , shift , & mut next_zeros , & mut next_ones , & mut curr_bits , curr_zeros . len ( ) as u64 , ) ; curr_zeros = next_zeros ; curr_ones = next_ones ; let level = RankSelect :: new ( curr_bits , 1 ) ; levels . push ( level ) ; zeros . push ( curr_zeros . len ( ) as u64 ) ; } WaveletMatrix { width , height , zeros , levels , } }
Construct a new instance of the wavelet matrix of given text of length n (DNA alphabet plus sentinel symbol).
Construct a new instance of the wavelet matrix of given text of length n ( DNA alphabet plus sentinel symbol ) .
text
&[u8]